Helma Logo
main list history

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

1This page describes how to set up *Apache log4j|http://logging.apache.org/log4j/* with Helma.
3<ol>
4<li> First step obviously is to download log4j, you will get it at there: http://logging.apache.org/log4j/docs/download.html </li>
5
6<li> Place the log4j jar in your lib/ext directory within Helma.</li>
7
8<li> Activate log4j by setting the loggerFactory property in your *server.properties|server and application properties*.
9
10<pre>loggerFactory=org.apache.commons.logging.impl.LogFactoryImpl</pre>
11
12This 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>
13
14<li> Create a log4J config. A simple config could look like this:
15
16<pre>
17log4j.rootLogger = DEBUG, console
18log4j.logger.helma.antville = DEBUG, console, chainsaw
19
20log4j.appender.chainsaw = org.apache.log4j.net.SocketAppender
21log4j.appender.chainsaw.remoteHost = localhost
22log4j.appender.chainsaw.port = 4445
23log4j.appender.chainsaw.locationInfo = true
24
25log4j.appender.console = org.apache.log4j.ConsoleAppender
26log4j.appender.console.layout = org.apache.log4j.PatternLayout
27log4j.appender.console.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n
28log4j.appender.console.threshold = WARN
29</pre>
30
31This 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.
32
33You can place the config wherever you like.</li>
34
35<li> Tell log4j to use that config by setting a java system property. Best place to do that is your start.sh / start.bat.
36
37<pre>
38:: Uncomment to pass options to the Java virtual machine
39set JAVA_OPTIONS=-server -Xmx128m -Dlog4j.configuration=file:/c:/log4j.conf
40</pre></li>
41
42<li> Eveything done, start Helma!</li>
43</ol>
44
45Of 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 (-;