public class SimpleLogger extends MarkerIgnoringBase
System.err).
The output includes the relative time in milliseconds, thread
name, the level, logger name, and the message followed by the line
separator for the host. In log4j terms it amounts to the "%r [%t]
%level %logger - %m%n" pattern.
Sample output follows.
176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order.
225 [main] INFO examples.SortAlgo - Entered the sort method.
304 [main] INFO examples.SortAlgo - Dump of integer array:
317 [main] INFO examples.SortAlgo - Element [0] = 0
331 [main] INFO examples.SortAlgo - Element [1] = 1
343 [main] INFO examples.Sort - The next log statement should be an error message.
346 [main] ERROR examples.SortAlgo - Tried to dump an uninitialized array.
at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
at org.log4j.examples.Sort.main(Sort.java:64)
467 [main] INFO examples.Sort - Exiting main method.
Modifier and Type | Field and Description |
---|---|
static String |
LINE_SEPARATOR |
protected String |
name |
ROOT_LOGGER_NAME
Modifier and Type | Method and Description |
---|---|
void |
debug(String msg)
A NOP implementation, as this logger is permanently disabled for
the DEBUG level.
|
void |
debug(String format,
Object param1)
A NOP implementation, as this logger is permanently disabled for
the DEBUG level.
|
void |
debug(String format,
Object[] argArray)
Log a message at the DEBUG level according to the specified format
and arguments.
|
void |
debug(String format,
Object param1,
Object param2)
A NOP implementation, as this logger is permanently disabled for
the DEBUG level.
|
void |
debug(String msg,
Throwable t)
A NOP implementation, as this logger is permanently disabled for
the DEBUG level.
|
void |
error(String msg)
A simple implementation which always logs messages of level ERROR according
to the format outlined above.
|
void |
error(String format,
Object arg)
Perform single parameter substitution before logging the message of level
ERROR according to the format outlined above.
|
void |
error(String format,
Object[] argArray)
Perform double parameter substitution before logging the message of level
ERROR according to the format outlined above.
|
void |
error(String format,
Object arg1,
Object arg2)
Perform double parameter substitution before logging the message of level
ERROR according to the format outlined above.
|
void |
error(String msg,
Throwable t)
Log a message of level ERROR, including an exception.
|
String |
getName()
Return the name of this
Logger instance. |
void |
info(String msg)
A simple implementation which always logs messages of level INFO according
to the format outlined above.
|
void |
info(String format,
Object arg)
Perform single parameter substitution before logging the message of level
INFO according to the format outlined above.
|
void |
info(String format,
Object[] argArray)
Perform double parameter substitution before logging the message of level
INFO according to the format outlined above.
|
void |
info(String format,
Object arg1,
Object arg2)
Perform double parameter substitution before logging the message of level
INFO according to the format outlined above.
|
void |
info(String msg,
Throwable t)
Log a message of level INFO, including an exception.
|
boolean |
isDebugEnabled()
Always returns false.
|
boolean |
isErrorEnabled()
Always returns true.
|
boolean |
isInfoEnabled()
Always returns true.
|
boolean |
isTraceEnabled()
Always returns false.
|
boolean |
isWarnEnabled()
Always returns true.
|
protected Object |
readResolve()
Replace this instance with a homonymous (same name) logger returned
by LoggerFactory.
|
void |
trace(String msg)
A NOP implementation, as this logger is permanently disabled for
the TRACE level.
|
void |
trace(String format,
Object param1)
A NOP implementation, as this logger is permanently disabled for
the TRACE level.
|
void |
trace(String format,
Object[] argArray)
Log a message at the TRACE level according to the specified format
and arguments.
|
void |
trace(String format,
Object param1,
Object param2)
A NOP implementation, as this logger is permanently disabled for
the TRACE level.
|
void |
trace(String msg,
Throwable t)
A NOP implementation, as this logger is permanently disabled for
the TRACE level.
|
void |
warn(String msg)
A simple implementation which always logs messages of level WARN according
to the format outlined above.
|
void |
warn(String format,
Object arg)
Perform single parameter substitution before logging the message of level
WARN according to the format outlined above.
|
void |
warn(String format,
Object[] argArray)
Perform double parameter substitution before logging the message of level
WARN according to the format outlined above.
|
void |
warn(String format,
Object arg1,
Object arg2)
Perform double parameter substitution before logging the message of level
WARN according to the format outlined above.
|
void |
warn(String msg,
Throwable t)
Log a message of level WARN, including an exception.
|
debug, debug, debug, debug, debug, error, error, error, error, error, info, info, info, info, info, isDebugEnabled, isErrorEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, toString, trace, trace, trace, trace, trace, warn, warn, warn, warn, warn
public boolean isTraceEnabled()
public void trace(String msg)
msg
- the message string to be loggedpublic void trace(String format, Object param1)
format
- the format stringparam1
- the argumentpublic void trace(String format, Object param1, Object param2)
format
- the format stringparam1
- the first argumentparam2
- the second argumentpublic void trace(String format, Object[] argArray)
Logger
This form avoids superfluous object creation when the logger is disabled for the TRACE level.
format
- the format stringargArray
- an array of argumentspublic void trace(String msg, Throwable t)
msg
- the message accompanying the exceptiont
- the exception (throwable) to logpublic boolean isDebugEnabled()
public void debug(String msg)
msg
- the message string to be loggedpublic void debug(String format, Object param1)
format
- the format stringparam1
- the argumentpublic void debug(String format, Object param1, Object param2)
format
- the format stringparam1
- the first argumentparam2
- the second argumentpublic void debug(String format, Object[] argArray)
Logger
This form avoids superfluous object creation when the logger is disabled for the DEBUG level.
format
- the format stringargArray
- an array of argumentspublic void debug(String msg, Throwable t)
msg
- the message accompanying the exceptiont
- the exception (throwable) to logpublic boolean isInfoEnabled()
public void info(String msg)
msg
- the message string to be loggedpublic void info(String format, Object arg)
format
- the format stringarg
- the argumentpublic void info(String format, Object arg1, Object arg2)
format
- the format stringarg1
- the first argumentarg2
- the second argumentpublic void info(String format, Object[] argArray)
format
- the format stringargArray
- an array of argumentspublic void info(String msg, Throwable t)
msg
- the message accompanying the exceptiont
- the exception (throwable) to logpublic boolean isWarnEnabled()
public void warn(String msg)
msg
- the message string to be loggedpublic void warn(String format, Object arg)
format
- the format stringarg
- the argumentpublic void warn(String format, Object arg1, Object arg2)
format
- the format stringarg1
- the first argumentarg2
- the second argumentpublic void warn(String format, Object[] argArray)
format
- the format stringargArray
- an array of argumentspublic void warn(String msg, Throwable t)
msg
- the message accompanying the exceptiont
- the exception (throwable) to logpublic boolean isErrorEnabled()
public void error(String msg)
msg
- the message string to be loggedpublic void error(String format, Object arg)
format
- the format stringarg
- the argumentpublic void error(String format, Object arg1, Object arg2)
format
- the format stringarg1
- the first argumentarg2
- the second argumentpublic void error(String format, Object[] argArray)
format
- the format stringargArray
- an array of argumentspublic void error(String msg, Throwable t)
msg
- the message accompanying the exceptiont
- the exception (throwable) to logpublic String getName()
Logger
Logger
instance.protected Object readResolve() throws ObjectStreamException
This approach will work well if the desired ILoggerFactory is the one references by LoggerFactory. However, if the user manages its logger hierarchy through a different (non-static) mechanism, e.g. dependency injection, then this approach would be mostly counterproductive.
ObjectStreamException
Copyright © 2005-2012 QOS.ch. All Rights Reserved.