org.apache.log4j
Class Logger

java.lang.Object
  extended by org.apache.log4j.Category
      extended by org.apache.log4j.Logger

public class Logger
extends Category

This is the central class in the log4j package. Most logging operations, except configuration, are done through this class.

NOTE: This is NOT the original file of Log4J Logger, and is only here to provide a static mapping to the Pax Logging system running under OSGi.

The client code that wishes to use this adaptation of Log4J and have the log output to be directed to the Pax Logging Service backend, which is driven by the real Log4J, it is necessary to;

Author:
Ceki Gülcü, Niclas Hedhman

Field Summary
 
Fields inherited from class org.apache.log4j.Category
m_delegate
 
Method Summary
 void debug(java.lang.Object message)
          Log a message object with the DEBUG level.
 void debug(java.lang.Object messagePattern, java.lang.Object arg)
          Log a message with the DEBUG level with message formatting done according to the value of messagePattern and arg parameters.
 void debug(java.lang.Object message, java.lang.Throwable t)
          Log a message object with the DEBUG level including the stack trace of the Throwablet passed as parameter.
 void debug(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
          Log a message with the DEBUG level with message formatting done according to the messagePattern and the arguments arg1 and arg2.
static void dispose()
          Pax Logging internal method.
 void error(java.lang.Object message)
          Log a message object with the ERROR Level.
 void error(java.lang.Object messagePattern, java.lang.Object arg)
          Log a message with the ERROR level with message formatting done according to the value of messagePattern and arg parameters.
 void error(java.lang.Object message, java.lang.Throwable t)
          Log a message object with the ERROR level including the stack trace of the Throwablet passed as parameter.
 void error(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
          Log a message with the ERROR level with message formatting done according to the messagePattern and the arguments arg1 and arg2.
 void fatal(java.lang.Object message)
          Log a message object with the FATAL Level.
 void fatal(java.lang.Object messagePattern, java.lang.Object arg)
          Log a message with the FATAL level with message formatting done according to the value of messagePattern and arg parameters.
 void fatal(java.lang.Object message, java.lang.Throwable t)
          Log a message object with the FATAL level including the stack trace of the Throwablet passed as parameter.
 void fatal(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
          Log a message with the FATAL level with message formatting done according to the messagePattern and the arguments arg1 and arg2.
static Logger getLogger(java.lang.Class clazz)
          Shorthand for getLogger(clazz.getName()).
static Logger getLogger(java.lang.String name)
          Retrieve a logger by name.
static Logger getLogger(java.lang.String name, LoggerFactory factory)
          This method is equivalent to getLogger( String name ) and the LoggerFactory is ignored.
static Logger getRootLogger()
          Return the root of logger for the current hierarchy.
 void info(java.lang.Object message)
          Log a message object with the INFO Level.
 void info(java.lang.Object messagePattern, java.lang.Object arg)
          Log a message with the INFO level with message formatting done according to the value of messagePattern and arg parameters.
 void info(java.lang.Object message, java.lang.Throwable t)
          Log a message object with the INFO level including the stack trace of the Throwablet passed as parameter.
 void info(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
          Log a message with the INFO level with message formatting done according to the messagePattern and the arguments arg1 and arg2.
 boolean isErrorEnabled()
          Check whether this category is enabled for the ERROR Level.
 boolean isTraceEnabled()
          Check whether this category is enabled for the TRACE Level.
 boolean isWarnEnabled()
          Check whether this category is enabled for the WARN Level.
static void release()
          Lifecycle method to release any resources held.
static void setBundleContext(org.osgi.framework.BundleContext ctx)
           
 void trace(java.lang.Object message)
          Log a message object with the TRACE level.
 void trace(java.lang.Object messagePattern, java.lang.Object arg)
          Log a message with the TRACE level with message formatting done according to the value of messagePattern and arg parameters.
 void trace(java.lang.Object message, java.lang.Throwable t)
          Log a message object with the TRACE level including the stack trace of the Throwablet passed as parameter.
 void trace(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
          Log a message with the TRACE level with message formatting done according to the messagePattern and the arguments arg1 and arg2.
 void warn(java.lang.Object message)
          Log a message object with the WARN Level.
 void warn(java.lang.Object messagePattern, java.lang.Object arg)
          Log a message with the WARN level with message formatting done according to the value of messagePattern and arg parameters.
 void warn(java.lang.Object message, java.lang.Throwable t)
          Log a message with the WARN level including the stack trace of the Throwablet passed as parameter.
 void warn(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
          Log a message with the WARN level with message formatting done according to the messagePattern and the arguments arg1 and arg2.
 
Methods inherited from class org.apache.log4j.Category
assertLog, getInstance, getInstance, getName, isDebugEnabled, isEnabledFor, isInfoEnabled, log, log, log, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setBundleContext

public static void setBundleContext(org.osgi.framework.BundleContext ctx)

release

public static void release()
Lifecycle method to release any resources held.


getLogger

public static Logger getLogger(java.lang.String name)
Retrieve a logger by name. If the named logger already exists, then the existing instance will be reutrned. Otherwise, a new instance is created.

By default, loggers do not have a set level but inherit it from their ancestors. This is one of the central features of log4j.

Parameters:
name - The name of the logger to retrieve.
Returns:
the Logger instance of the given name.

getLogger

public static Logger getLogger(java.lang.Class clazz)
Shorthand for getLogger(clazz.getName()).

Parameters:
clazz - The name of clazz will be used as the name of the logger to retrieve. See getLogger(String) for more detailed information.
Returns:
the Logger instance for the given class.

getRootLogger

public static Logger getRootLogger()
Return the root of logger for the current hierarchy.

The root logger is always instantiated and available. It's name is "root".

Nevertheless, note that calling Logger.getLogger("root") does not retrieve the root logger but a logger just under root named "root".

Returns:
the top-most Logger instance, which does not have a name.

getLogger

public static Logger getLogger(java.lang.String name,
                               LoggerFactory factory)
This method is equivalent to getLogger( String name ) and the LoggerFactory is ignored. The method exists only to improve compatibility with Log4J.

Parameters:
name - The name of the logger to retrieve.
factory - Ignored!
Returns:
the Logger instance of the given name.
Since:
Pax Logging 0.9.5

trace

public void trace(java.lang.Object message)
Log a message object with the TRACE level.

Parameters:
message - the message object to log.
Since:
1.2.12
See Also:
for an explanation of the logic applied.

trace

public void trace(java.lang.Object message,
                  java.lang.Throwable t)
Log a message object with the TRACE level including the stack trace of the Throwablet passed as parameter.

See debug(Object) form for more detailed information.

Specified by:
trace in class Category
Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.
Since:
1.2.12

trace

public void trace(java.lang.Object messagePattern,
                  java.lang.Object arg)
Log a message with the TRACE level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg - The argument to replace the formatting element, i,e, the '{}' pair within messagePattern.
Since:
1.3

trace

public void trace(java.lang.String messagePattern,
                  java.lang.Object arg1,
                  java.lang.Object arg2)
Log a message with the TRACE level with message formatting done according to the messagePattern and the arguments arg1 and arg2.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg1 - The first argument to replace the first formatting element
arg2 - The second argument to replace the second formatting element
Since:
1.3

fatal

public void fatal(java.lang.String messagePattern,
                  java.lang.Object arg1,
                  java.lang.Object arg2)
Log a message with the FATAL level with message formatting done according to the messagePattern and the arguments arg1 and arg2.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg1 - The first argument to replace the first formatting element
arg2 - The second argument to replace the second formatting element
Since:
1.3

debug

public void debug(java.lang.Object messagePattern,
                  java.lang.Object arg)
Log a message with the DEBUG level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg - The argument to replace the formatting element, i,e, the '{}' pair within messagePattern.
Since:
1.3

debug

public void debug(java.lang.String messagePattern,
                  java.lang.Object arg1,
                  java.lang.Object arg2)
Log a message with the DEBUG level with message formatting done according to the messagePattern and the arguments arg1 and arg2.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg1 - The first argument to replace the first formatting element
arg2 - The second argument to replace the second formatting element
Since:
1.3

isErrorEnabled

public boolean isErrorEnabled()
Check whether this category is enabled for the ERROR Level. See also Category.isDebugEnabled().

Returns:
boolean - true if this category is enabled for level ERROR, false otherwise.

error

public void error(java.lang.Object messagePattern,
                  java.lang.Object arg)
Log a message with the ERROR level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg - The argument to replace the formatting element, i,e, the '{}' pair within messagePattern.
Since:
1.3

error

public void error(java.lang.String messagePattern,
                  java.lang.Object arg1,
                  java.lang.Object arg2)
Log a message with the ERROR level with message formatting done according to the messagePattern and the arguments arg1 and arg2.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg1 - The first argument to replace the first formatting element
arg2 - The second argument to replace the second formatting element
Since:
1.3

fatal

public void fatal(java.lang.Object messagePattern,
                  java.lang.Object arg)
Log a message with the FATAL level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg - The argument to replace the formatting element, i,e, the '{}' pair within messagePattern.
Since:
1.3

info

public void info(java.lang.Object messagePattern,
                 java.lang.Object arg)
Log a message with the INFO level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg - The argument to replace the formatting element, i,e, the '{}' pair within messagePattern.
Since:
1.3

info

public void info(java.lang.String messagePattern,
                 java.lang.Object arg1,
                 java.lang.Object arg2)
Log a message with the INFO level with message formatting done according to the messagePattern and the arguments arg1 and arg2.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg1 - The first argument to replace the first formatting element
arg2 - The second argument to replace the second formatting element
Since:
1.3

isTraceEnabled

public boolean isTraceEnabled()
Check whether this category is enabled for the TRACE Level. See also Category.isDebugEnabled().

Returns:
boolean - true if this category is enabled for level TRACE, false otherwise.

isWarnEnabled

public boolean isWarnEnabled()
Check whether this category is enabled for the WARN Level. See also Category.isDebugEnabled().

Returns:
boolean - true if this category is enabled for level WARN, false otherwise.

warn

public void warn(java.lang.Object messagePattern,
                 java.lang.Object arg)
Log a message with the WARN level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg - The argument to replace the formatting element, i,e, the '{}' pair within messagePattern.
Since:
1.3

warn

public void warn(java.lang.String messagePattern,
                 java.lang.Object arg1,
                 java.lang.Object arg2)
Log a message with the WARN level with message formatting done according to the messagePattern and the arguments arg1 and arg2.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.

Parameters:
messagePattern - The message pattern which will be parsed and formatted
arg1 - The first argument to replace the first formatting element
arg2 - The second argument to replace the second formatting element
Since:
1.3

debug

public void debug(java.lang.Object message)
Description copied from class: Category
Log a message object with the DEBUG level.

This method first checks if this category is DEBUG enabled by comparing the level of this category with the DEBUG level. If this category is DEBUG enabled, then it converts the message object (passed as parameter) to a string by invoking the appropriate org.apache.log4j.or.ObjectRenderer. It then proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the Category.debug(Object,Throwable) form instead.

Overrides:
debug in class Category
Parameters:
message - the message object to log.

debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)
Description copied from class: Category
Log a message object with the DEBUG level including the stack trace of the Throwablet passed as parameter.

See Category.debug(Object) form for more detailed information.

Overrides:
debug in class Category
Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

error

public void error(java.lang.Object message)
Description copied from class: Category
Log a message object with the ERROR Level.

This method first checks if this category is ERROR enabled by comparing the level of this category with ERROR Level. If this category is ERROR enabled, then it converts the message object passed as parameter to a string by invoking the appropriate org.apache.log4j.or.ObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the Category.error(Object,Throwable) form instead.

Overrides:
error in class Category
Parameters:
message - the message object to log

error

public void error(java.lang.Object message,
                  java.lang.Throwable t)
Description copied from class: Category
Log a message object with the ERROR level including the stack trace of the Throwablet passed as parameter.

See Category.error(Object) form for more detailed information.

Overrides:
error in class Category
Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

fatal

public void fatal(java.lang.Object message)
Description copied from class: Category
Log a message object with the FATAL Level.

This method first checks if this category is FATAL enabled by comparing the level of this category with FATAL Level. If the category is FATAL enabled, then it converts the message object passed as parameter to a string by invoking the appropriate org.apache.log4j.or.ObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the Category.fatal(Object,Throwable) form instead.

Overrides:
fatal in class Category
Parameters:
message - the message object to log

fatal

public void fatal(java.lang.Object message,
                  java.lang.Throwable t)
Description copied from class: Category
Log a message object with the FATAL level including the stack trace of the Throwablet passed as parameter.

See Category.fatal(Object) for more detailed information.

Overrides:
fatal in class Category
Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

info

public void info(java.lang.Object message)
Description copied from class: Category
Log a message object with the INFO Level.

This method first checks if this category is INFO enabled by comparing the level of this category with INFO Level. If the category is INFO enabled, then it converts the message object passed as parameter to a string by invoking the appropriate org.apache.log4j.or.ObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hierarchy depending on the value of the additivity flag.

WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the Category.info(Object,Throwable) form instead.

Overrides:
info in class Category
Parameters:
message - the message object to log

info

public void info(java.lang.Object message,
                 java.lang.Throwable t)
Description copied from class: Category
Log a message object with the INFO level including the stack trace of the Throwablet passed as parameter.

See Category.info(Object) for more detailed information.

Overrides:
info in class Category
Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

warn

public void warn(java.lang.Object message)
Description copied from class: Category
Log a message object with the WARN Level.

This method first checks if this category is WARN enabled by comparing the level of this category with WARN Level. If the category is WARN enabled, then it converts the message object passed as parameter to a string by invoking the appropriate org.apache.log4j.or.ObjectRenderer. It proceeds to call all the registered appenders in this category and also higher in the hieararchy depending on the value of the additivity flag.

WARNING Note that passing a Throwable to this method will print the name of the Throwable but no stack trace. To print a stack trace use the Category.warn(Object,Throwable) form instead.

Overrides:
warn in class Category
Parameters:
message - the message object to log.

warn

public void warn(java.lang.Object message,
                 java.lang.Throwable t)
Description copied from class: Category
Log a message with the WARN level including the stack trace of the Throwablet passed as parameter.

See Category.warn(Object) for more detailed information.

Overrides:
warn in class Category
Parameters:
message - the message object to log.
t - the exception to log, including its stack trace.

dispose

public static void dispose()
Pax Logging internal method. Should never be used directly.



Copyright © 2006-2011 OPS4J - Open Participation Software for Java. All Rights Reserved.