Helma Logo
main list history
previous version  overview  next version

Version 1 by hannes on 17. February 2009, 22:48

This page describes how to set up *Apache log4j|http://logging.apache.org/log4j/* with Helma.

<ol>
<li> First step obviously is to download log4j, you will get it at there: http://logging.apache.org/log4j/docs/download.html </li>

<li> Place the log4j jar in your lib/ext directory within Helma.</li>

<li> Activate log4j by setting the loggerFactory property in your *server.properties|server and application properties*.

<pre>loggerFactory=org.apache.commons.logging.impl.LogFactoryImpl</pre>

This LogFactory implementation will <a href="http://jakarta.apache.org/commons/logging/apidocs/org/apache/commons/logging/impl/LogFactoryImpl.html">create a log4j logger</a> if log4j is found in the classpath.</li>

<li> Create a log4J config. A simple config could look like this:

<pre>
log4j.rootLogger = DEBUG, console
log4j.logger.helma.antville = DEBUG, console, chainsaw

log4j.appender.chainsaw = org.apache.log4j.net.SocketAppender
log4j.appender.chainsaw.remoteHost = localhost
log4j.appender.chainsaw.port = 4445
log4j.appender.chainsaw.locationInfo = true

log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n
log4j.appender.console.threshold = WARN
</pre>

This config file defines two appenders. One writes to the console, ignoring messages below WARN level, while the other sends all messages with level DEBUG or higher to a <a href="http://logging.apache.org/log4j/docs/api/org/apache/log4j/chainsaw/package-summary.html">log4j chainsaw log viewer</a> using a network socket. (Hint: Make sure you use the Chainsaw tool from the same log4j version Helma is using, otherwise it might not work.) Consult the <a href="http://logging.apache.org/log4j/docs/api/overview-tree.html">log4j documentation</a> or Google for other available Appender implementations.

You can place the config wherever you like.</li>

<li> Tell log4j to use that config by setting a java system property. Best place to do that is your start.sh / start.bat.

<pre>
:: Uncomment to pass options to the Java virtual machine
set JAVA_OPTIONS=-server -Xmx128m -Dlog4j.configuration=file:/c:/log4j.conf
</pre></li>

<li> Eveything done, start Helma!</li>
</ol>

Of course this all is still boring, now you will have to play on your own with all the possibilites log4J offers you. Just one hint: try using Chainsaw, the log4J logfile viewer - and you will love reading log files (-;

     removed
     added