Helma and log4j
This page describes how to set up Apache log4j with Helma.
- First step obviously is to download log4j, you will get it at there: http://logging.apache.org/log4j/docs/download.html
- Place the log4j jar in your lib/ext directory within Helma.
Activate log4j by setting the loggerFactory property in your server.properties.
loggerFactory=org.apache.commons.logging.impl.LogFactoryImplThis LogFactory implementation will create a log4j logger if log4j is found in the classpath.
Create a log4J config. A simple config could look like this:
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
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 log4j chainsaw log viewer 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 log4j documentation or Google for other available Appender implementations.You can place the config wherever you like.
Tell log4j to use that config by setting a java system property. Best place to do that is your start.sh / start.bat.
:: Uncomment to pass options to the Java virtual machine set JAVA_OPTIONS=-server -Xmx128m -Dlog4j.configuration=file:/c:/log4j.conf
- Eveything done, start Helma!
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 (-;