|
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.grlea.log.adapters.commons.CommonsLoggingAdapter
An adapter for using Simple Log within the Jakarta Commons Logging package.
Instructions for Use
To use this CommonsLoggingAdapter
with Commons Logging, simply
set the system property
'org.apache.commons.logging.Log
'
to 'org.grlea.log.adapters.commons.CommonsLoggingAdapter
'.
Implementation Details
The CommonsLoggingAdapter
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 Commons Logging levels are mapped to the Simple Log levels in this manner:
Commons Logging | Simple Log |
---|---|
Fatal | Fatal |
Error | Error |
Warn | Warn |
Info | Info |
Debug | Debug |
Trace |
Verbose |
"Tracing"
Note that the Commons Logging 'Trace' level is not matched to Simple
Log's tracing facility (i.e. SimpleLogger
's entry()
and
exit()
methdos), but to the Verbose
level. This is because the Commons Logging API allows any kind of object or exception to be
logged at the Trace level (rather than just method names), and provides no information
regarding whether the log is for a method entry or exit.
Logger Names
The Commons Logging 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.apache.commons.logging.Log
and with the provided logger name as the
instance ID of the logger. (See SimpleLogger.SimpleLogger(Class, Object)
. This means
that, when writing properties to configure loggers that don't use class names, the properties
should take the form:
org.apache.commons.logging.Log.<logger-name>
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.commons.supressWarnings
to
true
.
Object Rendering
Because Simple Log has a notion of logging message types (i.e. debug message, debug object and debug exception) but Commons Logging does not, the generic 'message' objects passed in to this adapter are passed on to Simple Log in this manner:
fatal(Object)
or fatal(Object, Throwable)
) is passed onto the SimpleLogger.db(org.grlea.log.DebugLevel, java.lang.String)
method.
Object
passed in as the 'message' argument is passed onto the
SimpleLogger.dbo(org.grlea.log.DebugLevel, java.lang.String, java.lang.Object)
method as an object whose vaue is to be debugged, with the empty
string as the object name.
fatal(Object, Throwable)
result in an additional call to the
SimpleLogger.dbe(org.grlea.log.DebugLevel, java.lang.Throwable)
method.
Constructor Summary | |
CommonsLoggingAdapter(java.lang.String loggerName)
|
Method Summary | |
void |
debug(java.lang.Object message)
|
void |
debug(java.lang.Object message,
java.lang.Throwable t)
|
void |
error(java.lang.Object message)
|
void |
error(java.lang.Object message,
java.lang.Throwable t)
|
void |
fatal(java.lang.Object message)
|
void |
fatal(java.lang.Object message,
java.lang.Throwable t)
|
void |
info(java.lang.Object message)
|
void |
info(java.lang.Object message,
java.lang.Throwable t)
|
boolean |
isDebugEnabled()
|
boolean |
isErrorEnabled()
|
boolean |
isFatalEnabled()
|
boolean |
isInfoEnabled()
|
boolean |
isTraceEnabled()
|
boolean |
isWarnEnabled()
|
static void |
setLog(SimpleLog simpleLog)
|
void |
trace(java.lang.Object message)
|
void |
trace(java.lang.Object message,
java.lang.Throwable t)
|
void |
warn(java.lang.Object message)
|
void |
warn(java.lang.Object message,
java.lang.Throwable t)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CommonsLoggingAdapter(java.lang.String loggerName)
Method Detail |
public static void setLog(SimpleLog simpleLog)
public boolean isFatalEnabled()
isFatalEnabled
in interface Log
public boolean isErrorEnabled()
isErrorEnabled
in interface Log
public boolean isWarnEnabled()
isWarnEnabled
in interface Log
public boolean isInfoEnabled()
isInfoEnabled
in interface Log
public boolean isDebugEnabled()
isDebugEnabled
in interface Log
public boolean isTraceEnabled()
isTraceEnabled
in interface Log
public void fatal(java.lang.Object message)
fatal
in interface Log
public void fatal(java.lang.Object message, java.lang.Throwable t)
fatal
in interface Log
public void error(java.lang.Object message)
error
in interface Log
public void error(java.lang.Object message, java.lang.Throwable t)
error
in interface Log
public void warn(java.lang.Object message)
warn
in interface Log
public void warn(java.lang.Object message, java.lang.Throwable t)
warn
in interface Log
public void info(java.lang.Object message)
info
in interface Log
public void info(java.lang.Object message, java.lang.Throwable t)
info
in interface Log
public void debug(java.lang.Object message)
debug
in interface Log
public void debug(java.lang.Object message, java.lang.Throwable t)
debug
in interface Log
public void trace(java.lang.Object message)
trace
in interface Log
public void trace(java.lang.Object message, java.lang.Throwable t)
trace
in interface 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 |