Apache Jakarta Commons Logging integration.
See http://jakarta.apache.org/commons/logging.html
for more information.
Adapter classes for configuring the Commons Logging system
to use Syslog as the log implementation.
You can configure the Commons Logging system by creating a
file called "commons-logging.properties" in your
CLASSPATH with the following properties:
##
## Tells the Apache Jakarta Commons Logging package
## to use the Syslog adapter.
##
org.apache.commons.logging.LogFactory = com.protomatter.syslog.commons.SyslogChannelLogFactory
##
## XML configuration file for syslog. Required.
##
Syslog.config.xml = syslog.xml
##
## XML parser class name. Optional. You should only
## have to specify this if you get an exception loading
## the parser while configuring the adapter.
##
Syslog.xml.parser = org.apache.xerces.parsers.SAXParser
##
## Display the classloader warning if we're not being
## loaded by the system classloader? Optional,
## default is "on"
##
Syslog.classloader.warning = off
|
Then you can write code like this:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
...
Log log = LogFactory.getLog("foo.bar");
log.info("This is an info message");
log.error("This is an error message");
log.error("This is an error message", new Exception("Blah!"));
...
Log log = LogFactory.getLog(SomeClass.class);
log.debug("This is an info message");
log.warn("This is an error message");
log.warn("This is an error message", new Exception("Blah!"));
|
And the commons log API will route all calls to Syslog. The name
of the Log instance is used as the channel name to
send messages to. The isTraceEnabled() and
isDebugEnabled() methods are passthroughs to
the on() method of and instance of the
Debug class
with the same name as the Log instance.
Note that if you use these classes, and don't have Syslog configured to compute
the caller class and method, then the caller name in your logs will be
incorrect. This is because the Apache Jakarta Commons Logging API doesn't have
a mechanism for directly getting a reference to the caller.
|