|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.log4j.Logger
public class Logger
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;
| 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. |
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 . |
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 |
isDebugEnabled()
Check whether this category is enabled for the DEBUG Level. |
boolean |
isEnabledFor(Priority priority)
Check whether this category is enabled for the given Level. |
boolean |
isErrorEnabled()
Check whether this category is enabled for the ERROR Level. |
boolean |
isInfoEnabled()
Check whether this category is enabled for the info 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. |
void |
log(Priority priority,
java.lang.Object msg)
Log a message with the code level priority. |
void |
log(Priority priority,
java.lang.Object message,
java.lang.Throwable t)
This generic form is intended to be used by wrappers. |
void |
log(java.lang.String callerFQCN,
Priority level,
java.lang.Object message,
java.lang.Throwable t)
This is the most generic printing method. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void setBundleContext(org.osgi.framework.BundleContext ctx)
public static void release()
public static Logger getLogger(java.lang.String name)
By default, loggers do not have a set level but inherit it from their ancestors. This is one of the central features of log4j.
name - The name of the logger to retrieve.
public static Logger getLogger(java.lang.Class clazz)
getLogger(clazz.getName()).
clazz - The name of clazz will be used as the name of
the logger to retrieve. See getLogger(String) for
more detailed information.
public static Logger getRootLogger()
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".
public static Logger getLogger(java.lang.String name,
LoggerFactory factory)
getLogger( String name ) and the
LoggerFactory is ignored. The method exists only to improve compatibility with
Log4J.
name - The name of the logger to retrieve.factory - Ignored!
public void trace(java.lang.Object message)
message - the message object to log.for an explanation of the logic applied.
public void trace(java.lang.Object message,
java.lang.Throwable t)
TRACE level including the
stack trace of the Throwablet passed as parameter.
See debug(Object) form for more detailed information.
message - the message object to log.t - the exception to log, including its stack trace.
public void trace(java.lang.Object messagePattern,
java.lang.Object arg)
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.
messagePattern - The message pattern which will be parsed and formattedarg - The argument to replace the formatting element, i,e,
the '{}' pair within messagePattern.
public void trace(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
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.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting element
public void fatal(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
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.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting elementpublic void debug(java.lang.Object message)
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 debug(Object,Throwable) form
instead.
message - the message object to log.
public void debug(java.lang.Object message,
java.lang.Throwable t)
DEBUG level including the
stack trace of the Throwablet passed as parameter.
See debug(Object) form for more detailed information.
message - the message object to log.t - the exception to log, including its stack trace.
public void debug(java.lang.Object messagePattern,
java.lang.Object arg)
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.
messagePattern - The message pattern which will be parsed and formattedarg - The argument to replace the formatting element, i,e,
the '{}' pair within messagePattern.
public void debug(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
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.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting elementpublic boolean isErrorEnabled()
isDebugEnabled().
true if this category is enabled for level
ERROR, false otherwise.public void error(java.lang.Object message)
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 error(Object,Throwable) form
instead.
message - the message object to log
public void error(java.lang.Object message,
java.lang.Throwable t)
ERROR level including the
stack trace of the Throwablet passed as parameter.
See error(Object) form for more detailed information.
message - the message object to log.t - the exception to log, including its stack trace.
public void error(java.lang.Object messagePattern,
java.lang.Object arg)
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.
messagePattern - The message pattern which will be parsed and formattedarg - The argument to replace the formatting element, i,e,
the '{}' pair within messagePattern.
public void error(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
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.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting elementpublic void fatal(java.lang.Object message)
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 fatal(Object,Throwable) form instead.
message - the message object to log
public void fatal(java.lang.Object messagePattern,
java.lang.Object arg)
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.
messagePattern - The message pattern which will be parsed and formattedarg - The argument to replace the formatting element, i,e,
the '{}' pair within messagePattern.
public void fatal(java.lang.Object message,
java.lang.Throwable t)
FATAL level including the
stack trace of the Throwablet passed as parameter.
See fatal(Object) for more detailed information.
message - the message object to log.t - the exception to log, including its stack trace.public void info(java.lang.Object message)
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 info(Object,Throwable) form instead.
message - the message object to log
public void info(java.lang.Object messagePattern,
java.lang.Object arg)
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.
messagePattern - The message pattern which will be parsed and formattedarg - The argument to replace the formatting element, i,e,
the '{}' pair within messagePattern.
public void info(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
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.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting element
public void info(java.lang.Object message,
java.lang.Throwable t)
INFO level including the stack
trace of the Throwablet passed as parameter.
See info(Object) for more detailed information.
message - the message object to log.t - the exception to log, including its stack trace.public boolean isDebugEnabled()
DEBUG Level.
This function is intended to lessen the computational cost of disabled log debug statements.
For some cat Category object, when you write,
cat.debug("This is entry number: " + i );
You incur the cost constructing the message, concatenatiion in this case, regardless of whether the message is logged or not.
If you are worried about speed, then you should write
if(cat.isDebugEnabled()) {
cat.debug("This is entry number: " + i );
}
This way you will not incur the cost of parameter construction if
debugging is disabled for cat. On the other hand, if the
cat is debug enabled, you will incur the cost of evaluating
whether the category is debug enabled twice. Once in
isDebugEnabled and once in the debug. This is
an insignificant overhead since evaluating a category takes about 1%% of
the time it takes to actually log.
true if this category is debug enabled,
false otherwise.public boolean isTraceEnabled()
isDebugEnabled().
true if this category is enabled for level
TRACE, false otherwise.public boolean isInfoEnabled()
isDebugEnabled().
true if this category is enabled for level
info, false otherwise.public boolean isWarnEnabled()
isDebugEnabled().
true if this category is enabled for level
WARN, false otherwise.public boolean isEnabledFor(Priority priority)
priority - the level to check
true if this category is enabled for the given
level, false otherwise.public void warn(java.lang.Object message)
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 warn(Object,Throwable) form instead.
message - the message object to log.
public void warn(java.lang.Object message,
java.lang.Throwable t)
WARN level including the stack trace
of the Throwablet passed as parameter.
See warn(Object) for more detailed information.
message - the message object to log.t - the exception to log, including its stack trace.
public void warn(java.lang.Object messagePattern,
java.lang.Object arg)
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.
messagePattern - The message pattern which will be parsed and formattedarg - The argument to replace the formatting element, i,e,
the '{}' pair within messagePattern.
public void warn(java.lang.String messagePattern,
java.lang.Object arg1,
java.lang.Object arg2)
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.
messagePattern - The message pattern which will be parsed and formattedarg1 - The first argument to replace the first formatting elementarg2 - The second argument to replace the second formatting element
public void log(Priority priority,
java.lang.Object msg)
priority, - the code level of the messagemsg - the message object to log.
public void log(Priority priority,
java.lang.Object message,
java.lang.Throwable t)
public void log(java.lang.String callerFQCN,
Priority level,
java.lang.Object message,
java.lang.Throwable t)
callerFQCN - The wrapper class' fully qualified class name.level - The level of the logging request.message - The message of the logging request.t - The throwable of the logging request, may be null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||