com.opensymphony.util
Class Logger

java.lang.Object
  extended bycom.opensymphony.util.Logger
All Implemented Interfaces:
Serializable

Deprecated. If you require this functionality, we recommend you check out the Jakarta commons-logging project.

public class Logger
extends Object
implements Serializable

The Logger is a quick way of logging messages of different priorities.

Usage

In it's simplest form, place the following field in the class that uses the debugging:

private static Logger log = new Logger(ThisClassName.class);

Then to log messages, in your code use:

log.info("Debug message");

You can have several Loggers in the same class by using the ( Class, String ) constructor as follows:


     Logger logger     = newLogger( ThisClassName.class );         // For general logging.
     Logger loopLogger = newLogger( ThisClassName.class, "loop" ); // Just for logging my loop.

 

This will create a Logger with context com.somecompany.thispackage.ThisClassName.loop whose priority can be set from a config file independently of the main logger com.somecompany.thispackage.ThisClassName.

That's about it really. The types of log messages available (in order of severity - least first) are:

Each of these methods has a variation accepting a second parameter of type Throwable. This is useful for logging Exceptions or Errors that are thrown.

There are corresponding methods for isDebugEnabled() , isInfoEnabled() etc. to save the overhead of building the log string if the appropriate level is not set, as follows:


     if ( logger.isInfoEnabled() ) logger.info( "This " + methodCall() + " and the string "
                                              + "concatenation will only take place if "
                                              + "INFO debugging is currently enabled" );

 

The actual logging mechanism used depends on the configured LogProvider - this can be set using the logger.provider system property. If not specified, DefaultLogProvider is used.

Version:
$Revision: 1.1.1.1 $
Author:
Joe Walnes, Mike Cannon-Brookes, Dan North
See Also:
Serialized Form

Constructor Summary
Logger(Class cls)
          Deprecated. Convenience constructor.
Logger(Class cls, String subCategory)
          Deprecated. Convenience constructor.
Logger(Object obj)
          Deprecated. Convenience constructor.
Logger(String name)
          Deprecated. Create Logger with supplied context.
 
Method Summary
 void debug(Object o)
          Deprecated.  
 void debug(Object o, Throwable t)
          Deprecated.  
 void error(Object o)
          Deprecated.  
 void error(Object o, Throwable t)
          Deprecated.  
 void fatal(Object o)
          Deprecated.  
 void fatal(Object o, Throwable t)
          Deprecated.  
 void info(Object o)
          Deprecated.  
 void info(Object o, Throwable t)
          Deprecated.  
 boolean isDebugEnabled()
          Deprecated.  
 boolean isEnabledFor(int priority)
          Deprecated.  
 boolean isErrorEnabled()
          Deprecated.  
 boolean isFatalEnabled()
          Deprecated.  
 boolean isInfoEnabled()
          Deprecated.  
 boolean isWarnEnabled()
          Deprecated.  
 void log(int priority, Object o)
          Deprecated.  
 void log(int priority, Object o, Throwable t)
          Deprecated.  
 void warn(Object o)
          Deprecated.  
 void warn(Object o, Throwable t)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Logger

public Logger(String name)
Deprecated. 
Create Logger with supplied context.


Logger

public Logger(Class cls)
Deprecated. 
Convenience constructor. Calls Logger(java.lang.String) with cls.getName()


Logger

public Logger(Object obj)
Deprecated. 
Convenience constructor. Calls Logger(java.lang.String) with obj.getClass().getName()


Logger

public Logger(Class cls,
              String subCategory)
Deprecated. 
Convenience constructor. Creates the context string as the class name appended with the subcontext, with a "." if required.

Method Detail

isDebugEnabled

public boolean isDebugEnabled()
Deprecated. 

isEnabledFor

public boolean isEnabledFor(int priority)
Deprecated. 

isErrorEnabled

public boolean isErrorEnabled()
Deprecated. 

isFatalEnabled

public boolean isFatalEnabled()
Deprecated. 

isInfoEnabled

public boolean isInfoEnabled()
Deprecated. 

isWarnEnabled

public boolean isWarnEnabled()
Deprecated. 

debug

public void debug(Object o)
Deprecated. 

debug

public void debug(Object o,
                  Throwable t)
Deprecated. 

error

public void error(Object o)
Deprecated. 

error

public void error(Object o,
                  Throwable t)
Deprecated. 

fatal

public void fatal(Object o)
Deprecated. 

fatal

public void fatal(Object o,
                  Throwable t)
Deprecated. 

info

public void info(Object o)
Deprecated. 

info

public void info(Object o,
                 Throwable t)
Deprecated. 

log

public void log(int priority,
                Object o)
Deprecated. 

log

public void log(int priority,
                Object o,
                Throwable t)
Deprecated. 

warn

public void warn(Object o)
Deprecated. 

warn

public void warn(Object o,
                 Throwable t)
Deprecated. 

OSCore Project Page