By default, all logging is done to stdout. This probably isn't what
you want so it is wise to configure your logging to do something more
sensible.
Proxool uses Jakarta's Commons'
Logging
component.
"There are many logging APIs
out there and it is difficult to choose among them. The Logging package is an ultra-thin
bridge between different logging libraries.
This removes compile-time and
run-time dependencies on any particular logging package, and contributors may
write Log implementations for the library of their choice."
The following logging libraries are supported directly:
However, there is no reason why you shouldn't write your own implementation of
Log and log
wherever you wish.
Log4J Configuration
As an example, this is how we configure Log4J for use when we run Proxool's
unit tests.
First, create your configuration file (which we have called log4j.xml):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="general" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/var/log/proxool/general.log"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} [%-5p] %c {%F:%L} - %m%n"/>
</layout>
</appender>
<root>
<priority value="DEBUG"/>
<appender-ref ref="general"/>
</root>
</log4j:configuration>
This will log to /var/log/proxool/general.log and then archive the log every day to a new file.
You can easily log each pool to a different file. Just configure an appender for each pool and then
add the following <category> element just before the <root> element. For
example, to set up the log for the 'test' pool:
<category name="org.logicalcobwebs.proxool.test">
<appender-ref ref="test-appender"/>
</category>
And then you just need to point Log4J to that file:
org.apache.log4j.xml.DOMConfigurator.configureAndWatch(log4jPath);
Using Log4J's Chainsaw GUI log viewer
You might find it really useful to use Chainsaw (part of Log4J). It's a Java Swing application that will listen
to log events. You can even set it up to work on a different machine. All you have to do is setup
a special appender:
<appender name="chainsaw" class="org.apache.log4j.net.SocketAppender">
<param name="remoteHost" value="localhost"/>
<param name="port" value="4445"/>
<param name="locationInfo" value="true"/>
</appender>
And then you just startup Chainsaw:
java -classpath log4j.jar org.apache.log4j.chainsaw.Main
Obviously, you should include the correct path to your log4j.jar.
|