|
Simple Log 2.0.1
[grlea] |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.slf4j.impl.MarkerIgnoringBase org.grlea.log.adapters.slf4j.Slf4jAdapter
An adapter for using Simple Log within the SLF4J package.
Instructions for Use
To use this Slf4jAdapter
with SLF4J, you should only need to include the JARs for
Simple Log (simple-log.jar) and for the SLF4J Adapter (simple-log-slf4j.jar) in your classpath
and use the SLF4J LoggerFactory
to obtain log instances. Be careful not to confuse
'slf4j-simple.jar' as being part of the arrangement. It is a SLF4J deliverable that simply prints
output to System.out
.
Implementation Details
The Slf4jAdapter
always uses the
default SimpleLog
. It is anticipated this will do the job for
the preverbial 99% of cases. If this is insufficient for your needs, please write to me and we
can try and find a more flexible solution.
The SLF4J levels map directly to the Simple Log levels:
SLF4J | Simple Log |
---|---|
Error | Error |
Warn | Warn |
Info | Info |
Debug | Debug |
"Tracing"
Note that the SLF4J has no notion of tracing whatsoever, so the tracing properties in Simple Log will have no bearing on the output.
Logger Names
The SLF4J API provides logger names that are Strings, while Simple Log prefers Class
objects for naming its loggers. This adapter tries to rectify the discord by attempting to
interpret logger names as fully qualified class names.
Where this is not possible (because the logger name is not a class name), a
SimpleLogger
will be created using a source class of
org.slf4j.Logger
and with the provided logger name as the instance ID of the logger.
(See SimpleLogger.SimpleLogger(Class, Object)
.
When the two-argument domain + sub-domain method is used and the domain is not a fully-qualified
class name, the domain and sub-domain are concatenated with a period ('.') in between, e.g.
"domain.subdomain"
, and this is used as the instance ID.
This means that, when writing properties to configure loggers that don't use class names, the
properties should take the form:
org.slf4j.Logger.<logger-name>or
org.slf4j.Logger.<domain>.<subdomain>
When logger names cannot be interpreted as class names, each logger name that cannot be
interpreted will be printed with a warning to System.err
. You can supress these warnings
by setting the system property org.grlea.log.adapters.slf4j.supressWarnings
to
true
.
Object Rendering
Messages submitted to the Slf4jAdapter
using
the format + argument(s) methods
are interpreted using the
MessageFormatter
that is provided in SLF4J.
Method Summary | |
void |
debug(java.lang.String message)
Log a message at the DEBUG level. |
void |
debug(java.lang.String messageFormat,
java.lang.Object argument)
Log a message at the DEBUG level according to the specified format and argument. |
void |
debug(java.lang.String messageFormat,
java.lang.Object[] arguments)
Log a message at the DEBUG level according to the specified format and arguments. |
void |
debug(java.lang.String messageFormat,
java.lang.Object argument1,
java.lang.Object argument2)
Log a message at the DEBUG level according to the specified format and arguments. |
void |
debug(java.lang.String message,
java.lang.Throwable exception)
Log an exception (throwable) at the DEBUG level with an accompanying message. |
void |
error(java.lang.String message)
Log a message at the ERROR level. |
void |
error(java.lang.String messageFormat,
java.lang.Object argument)
Log a message at the ERROR level according to the specified format and argument. |
void |
error(java.lang.String messageFormat,
java.lang.Object[] arguments)
Log a message at the ERROR level according to the specified format and arguments. |
void |
error(java.lang.String messageFormat,
java.lang.Object argument1,
java.lang.Object argument2)
Log a message at the ERROR level according to the specified format and arguments. |
void |
error(java.lang.String message,
java.lang.Throwable exception)
Log an exception (throwable) at the ERROR level with an accompanying message. |
java.lang.String |
getName()
Return the name of this Logger instance. |
void |
info(java.lang.String message)
Log a message at the INFO level. |
void |
info(java.lang.String messageFormat,
java.lang.Object argument)
Log a message at the INFO level according to the specified format and argument. |
void |
info(java.lang.String messageFormat,
java.lang.Object[] arguments)
Log a message at the INFO level according to the specified format and arguments. |
void |
info(java.lang.String messageFormat,
java.lang.Object argument1,
java.lang.Object argument2)
Log a message at the INFO level according to the specified format and arguments. |
void |
info(java.lang.String message,
java.lang.Throwable exception)
Log an exception (throwable) at the INFO level with an accompanying message. |
boolean |
isDebugEnabled()
Is the logger instance enabled for the DEBUG level? |
boolean |
isErrorEnabled()
Is the logger instance enabled for the ERROR level? |
boolean |
isInfoEnabled()
Is the logger instance enabled for the INFO level? |
boolean |
isWarnEnabled()
Is the logger instance enabled for the WARN level? |
void |
warn(java.lang.String message)
Log a message at the WARN level. |
void |
warn(java.lang.String messageFormat,
java.lang.Object argument)
Log a message at the WARN level according to the specified format and argument. |
void |
warn(java.lang.String messageFormat,
java.lang.Object[] arguments)
Log a message at the WARN level according to the specified format and arguments. |
void |
warn(java.lang.String messageFormat,
java.lang.Object argument1,
java.lang.Object argument2)
Log a message at the WARN level according to the specified format and arguments. |
void |
warn(java.lang.String message,
java.lang.Throwable exception)
Log an exception (throwable) at the WARN level with an accompanying message. |
Methods inherited from class org.slf4j.impl.MarkerIgnoringBase |
debug, debug, debug, debug, debug, error, error, error, error, error, info, info, info, info, info, isDebugEnabled, isErrorEnabled, isInfoEnabled, isWarnEnabled, warn, warn, warn, warn, warn |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public java.lang.String getName()
Logger
Logger
instance.
public boolean isErrorEnabled()
Logger
public boolean isWarnEnabled()
Logger
public boolean isInfoEnabled()
Logger
public boolean isDebugEnabled()
Logger
public void error(java.lang.String message)
Logger
message
- the message string to be loggedpublic void error(java.lang.String messageFormat, java.lang.Object argument)
Logger
This form avoids superfluous object creation when the logger is disabled for the ERROR level.
messageFormat
- the format stringargument
- the argumentpublic void error(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
Logger
This form avoids superfluous object creation when the logger is disabled for the ERROR level.
messageFormat
- the format stringargument1
- the first argumentargument2
- the second argumentpublic void error(java.lang.String messageFormat, java.lang.Object[] arguments)
Logger
This form avoids superfluous object creation when the logger is disabled for the ERROR level.
messageFormat
- the format stringarguments
- an array of argumentspublic void error(java.lang.String message, java.lang.Throwable exception)
Logger
message
- the message accompanying the exceptionexception
- the exception (throwable) to logpublic void warn(java.lang.String message)
Logger
message
- the message string to be loggedpublic void warn(java.lang.String messageFormat, java.lang.Object argument)
Logger
This form avoids superfluous object creation when the logger is disabled for the WARN level.
messageFormat
- the format stringargument
- the argumentpublic void warn(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
Logger
This form avoids superfluous object creation when the logger is disabled for the WARN level.
messageFormat
- the format stringargument1
- the first argumentargument2
- the second argumentpublic void warn(java.lang.String messageFormat, java.lang.Object[] arguments)
Logger
This form avoids superfluous object creation when the logger is disabled for the WARN level.
messageFormat
- the format stringarguments
- an array of argumentspublic void warn(java.lang.String message, java.lang.Throwable exception)
Logger
message
- the message accompanying the exceptionexception
- the exception (throwable) to logpublic void info(java.lang.String message)
Logger
message
- the message string to be loggedpublic void info(java.lang.String messageFormat, java.lang.Object argument)
Logger
This form avoids superfluous object creation when the logger is disabled for the INFO level.
messageFormat
- the format stringargument
- the argumentpublic void info(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
Logger
This form avoids superfluous object creation when the logger is disabled for the INFO level.
messageFormat
- the format stringargument1
- the first argumentargument2
- the second argumentpublic void info(java.lang.String messageFormat, java.lang.Object[] arguments)
Logger
This form avoids superfluous object creation when the logger is disabled for the INFO level.
messageFormat
- the format stringarguments
- an array of argumentspublic void info(java.lang.String message, java.lang.Throwable exception)
Logger
message
- the message accompanying the exceptionexception
- the exception (throwable) to logpublic void debug(java.lang.String message)
Logger
message
- the message string to be loggedpublic void debug(java.lang.String messageFormat, java.lang.Object argument)
Logger
This form avoids superfluous object creation when the logger is disabled for the DEBUG level.
messageFormat
- the format stringargument
- the argumentpublic void debug(java.lang.String messageFormat, java.lang.Object argument1, java.lang.Object argument2)
Logger
This form avoids superfluous object creation when the logger is disabled for the DEBUG level.
messageFormat
- the format stringargument1
- the first argumentargument2
- the second argumentpublic void debug(java.lang.String messageFormat, java.lang.Object[] arguments)
Logger
This form avoids superfluous object creation when the logger is disabled for the DEBUG level.
messageFormat
- the format stringarguments
- an array of argumentspublic void debug(java.lang.String message, java.lang.Throwable exception)
Logger
message
- the message accompanying the exceptionexception
- the exception (throwable) to log
|
Copyright (c) 2004-2006, Graham Lea. All rights reserved. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |