Helma Logo
helma.org » Home > docs > howtos > Configuring Helma with log4j

Configuring Helma with log4j

This document describes how to use a feature rich logging system like log4j together with the Apache Commons Logging interface implemented into Helma.

You have Helma already running with Apache Commons Logging? You saw the changes to the default logger?

Then lets continue to use the power of log4j.

  1. First step obviously is to download log4j, you will get it at there: http://logging.apache.org/log4j/docs/download.html
  2. Place the log4j jar in your lib/ext directory within Helma.
  3. Activate log4j by setting the loggerFactory property in your server.properties.
    loggerFactory=org.apache.commons.logging.impl.LogFactoryImpl
    This LogFactory implementation will create a log4j logger if log4j is found in the classpath.
  4. 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.
  5. 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
    
  6. 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 (-;


Up: Deployment Guides
Previous: LAMTHA Next: Configuring Helma with MySQL

... comment


Page last modified on 2005-12-12 16:22 by czv

 
trigen, Tuesday, 2. December 2003, 12:42
thanks alot
couldn't find the SocketHubAppender config lines anywhere else =)

... link  

 
daniel, Tuesday, 2. December 2003, 21:19
SocketHubAppender
Did you use SocketHubAppender in any way?

For me it is the most interessting thing using log4J cause the SocketHubAppender streams log events to clients connected to it. So you can do live-remote-reading your log files, which Chainsaw (the log4J viewer) didn't support without some patches unfortunately at the time I wrote this.

... link  


... comment
 
janosb, Saturday, 19. November 2005, 15:14
Chainsaw command line/batch file
For people like me who are not that familiar with java: to use the helma-log4j version of chainsaw, write the commandline:
"java -classpath log4j-1.2.12.jar org.apache.log4j.chainsaw.Main"
or put it into a batch file.

... link  


... comment