Note: The latest developer snapshot of Chainsaw (available at can automatically build a Chainsaw configuration from existing fileappender entries - the process described below still works, but if you want to use the Chainsaw UI to build a configuration from an existing log4j.xml or, you can do that.

Automatic configuration

To automatically generate a Chainsaw configuration from an existing log4j.xml or file with fileappender entries, download the developer snapshot of Chainsaw (link above), then:

Manual configuration

Two files need to be configured to make the log4 RollingFileAppender work with Chainsaw


This file is of course used to configure the output from the log in log4j. The following are steps on how to configure it.

  1. Take special note in log4j.xml bellow of the log4j:configuration/appender/param@File
  2. Also take note in log4j.xml bellow of the log4j:configuration/appender/layout/param@ConverstionPattern

    • The value Attribute uspecifies the format in which the log will be written to the log file. <br/> This is also important to take note of since the ChainsawLogFileRecieverState.xml file we configure Chainsaw with needs to know what this is set at (with slightly diffrent syntax just to make things fun).

log4j.xml - Some where in whatever you are logging with this.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="">

        <appender name="FILE_APPENDER"
                <param name="File" value="c:/dev/logs/serverLog.log" />
                <param name="Append" value="true" />
                <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>

        <logger name="com.package.logger.LogClass">
                <level value="DEBUG"/>

                <level value="ERROR" />
                <appender-ref ref="FILE_APPENDER"/>



This is the file we are going to use to configure Chainsaw to read the log file output by log4j that we configured above. It isn't neccesary that we call it ChainsawLogFileRecieverState.xml, it can be called anything as long as:

The following are a few things to note as it is being configured.

  1. log4j:configuration/plugin/param@fileURL's value attribute in ChainsawLogFileRecieverState.xml points to the same log file that log4j.xml's log4j:configuration/appender/param@File does.

  2. Make sure that the timestampFormat that is being output in the log matches the one in ChainsawLogFileRecieverState.xml at log4j:configuration/plugin/param@timestampFormat

  3. Note that the ChainsawLogFileRecieverState.xml log4j:configuration/plugin/param@logFormat value matches the log4j.xml log4j:configuration/appender/layout/param@ConverstionPattern, and if that doesn't make sense see the table bellow.

Log4j/Chainsaw Pattern Layout Integration Table

log4j.xml PatternLayout





Used to output the date of the logging event



Used to output the priority of the logging event



Used to output the name of the thread that generated the logging event.



Used to output the fully qualified class name of the caller issuing the logging request



Used to output the file name where the logging request was issued.



Used to output the line number from where the logging request was issued.



Used to output the application supplied message associated with the logging event.



Outputs the platform dependent line separator character or characters.



The logger from which the message came

Also click the headers in this table for reference on where I got this information.

ChainsawLogFileRecieverState.xml - File read by Chainsaw

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="" debug="true">

   <plugin name="logFileReceiver" class="org.apache.log4j.varia.LogFilePatternReceiver">
     <param name="fileURL" value="file:///c:/dev/logs/serverLog.log" />
     <param name="timestampFormat" value="yyyy-MM-d HH:mm:ss,SSS"/>
     <param name="logFormat" value="TIMESTAMP LEVEL [THREAD] CLASS (FILE:LINE) - MESSAGE"/>
     <param name="name" value="Reciever-name-in-Chainsaw" />
     <param name="tailing" value="true" />

      <level value="debug"/>

Configuring_a_log4j_RollingFileAppender_with_Chainsaw (last edited 2012-02-23 22:24:49 by c-67-171-171-29)