|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.slf4j.helpers.MarkerIgnoringBase
org.slf4j.impl.SimpleLogger
public class SimpleLogger
Simple implementation of Logger
that sends all enabled log messages,
for all defined loggers, to the console (System.err
).
The following system properties are supported to configure the behavior of this logger:
org.slf4j.simplelogger.defaultlog
-
Default logging detail level for all instances of SimpleLogger.
Must be one of ("trace", "debug", "info", "warn", or "error").
If not specified, defaults to "info". org.slf4j.simplelogger.log.xxxxx
-
Logging detail level for a SimpleLogger instance named "xxxxx".
Must be one of ("trace", "debug", "info", "warn", or "error").
If not specified, the default logging detail level is used.org.slf4j.simplelogger.showdatetime
-
Set to true
if you want the current date and time
to be included in output messages. Default is false
,
and will output the number of milliseconds elapsed since startup.org.slf4j.simplelogger.dateTimeFormat
-
The date and time format to be used in the output messages.
The pattern describing the date and time format is the same that is
used in java.text.SimpleDateFormat
. If the format is not
specified or is invalid, the default format is used.
The default format is yyyy-MM-dd HH:mm:ss:SSS Z
.org.slf4j.simplelogger.showthreadname
-
Set to true
if you want to output the current thread name.
Defaults to true
.org.slf4j.simplelogger.showlogname
-
Set to true
if you want the Logger instance name to be
included in output messages. Defaults to true
.org.slf4j.simplelogger.showShortLogname
-
Set to true
if you want the last component of the name to be
included in output messages. Defaults to false
.In addition to looking for system properties with the names specified
above, this implementation also checks for a class loader resource named
"simplelogger.properties"
, and includes any matching definitions
from this resource (if it exists).
With no configurationn, the default 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.
This implementation is heavily inspired by Apache Commons Logging's SimpleLog.
Field Summary | |
---|---|
protected int |
currentLogLevel
The current log level |
static int |
LOG_LEVEL_ALL
Enable all logging levels |
static int |
LOG_LEVEL_DEBUG
"Debug" level logging. |
static int |
LOG_LEVEL_ERROR
"Error" level logging. |
static int |
LOG_LEVEL_INFO
"Info" level logging. |
static int |
LOG_LEVEL_OFF
Enable no logging levels |
static int |
LOG_LEVEL_TRACE
"Trace" level logging. |
static int |
LOG_LEVEL_WARN
"Warn" level logging. |
protected String |
name
|
Fields inherited from interface org.slf4j.Logger |
---|
ROOT_LOGGER_NAME |
Method Summary | |
---|---|
void |
debug(String msg)
A simple implementation which logs messages of level DEBUG according to the format outlined above. |
void |
debug(String format,
Object param1)
Perform single parameter substitution before logging the message of level DEBUG according to the format outlined above. |
void |
debug(String format,
Object[] argArray)
Perform double parameter substitution before logging the message of level DEBUG according to the format outlined above. |
void |
debug(String format,
Object param1,
Object param2)
Perform double parameter substitution before logging the message of level DEBUG according to the format outlined above. |
void |
debug(String msg,
Throwable t)
Log a message of level DEBUG, including an exception. |
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 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()
Are debug messages currently enabled? |
boolean |
isErrorEnabled()
Are error messages currently enabled? |
boolean |
isInfoEnabled()
Are info messages currently enabled? |
protected boolean |
isLevelEnabled(int logLevel)
Is the given log level currently enabled? |
boolean |
isTraceEnabled()
Are trace messages currently enabled? |
boolean |
isWarnEnabled()
Are warn messages currently enabled? |
protected Object |
readResolve()
Replace this instance with a homonymous (same name) logger returned by LoggerFactory. |
void |
trace(String msg)
A simple implementation which logs messages of level TRACE according to the format outlined above. |
void |
trace(String format,
Object param1)
Perform single parameter substitution before logging the message of level TRACE according to the format outlined above. |
void |
trace(String format,
Object[] argArray)
Perform double parameter substitution before logging the message of level TRACE according to the format outlined above. |
void |
trace(String format,
Object param1,
Object param2)
Perform double parameter substitution before logging the message of level TRACE according to the format outlined above. |
void |
trace(String msg,
Throwable t)
Log a message of level TRACE, including an exception. |
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. |
Methods inherited from class org.slf4j.helpers.MarkerIgnoringBase |
---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.slf4j.Logger |
---|
getName |
Field Detail |
---|
public static final int LOG_LEVEL_TRACE
public static final int LOG_LEVEL_DEBUG
public static final int LOG_LEVEL_INFO
public static final int LOG_LEVEL_WARN
public static final int LOG_LEVEL_ERROR
public static final int LOG_LEVEL_ALL
public static final int LOG_LEVEL_OFF
protected int currentLogLevel
protected String name
Method Detail |
---|
protected boolean isLevelEnabled(int logLevel)
logLevel
- is this level enabled?public boolean isTraceEnabled()
trace
messages currently enabled?
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)
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()
debug
messages currently enabled?
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)
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()
info
messages currently enabled?
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()
warn
messages currently enabled?
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()
error
messages currently enabled?
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.
getName
in interface Logger
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |