Apache logging services logo

How To view logging events using Apache log4j Chainsaw

Apache log4j™ includes Apache Chainsaw™ a graphical log viewer.

Chainsaw can either receive and display log events in realtime over the network, or it can load a previously created log file.

Before Chainsaw can display data, one or more receivers must be setup. This is usually done by specifying an xml config file when the program first starts up.
Save one or more of the sample xml config files to your local system and load them when Chainsaw starts.

Please note also that it may be necessary to configure Chainsaw tabs as reported as issue LOG4NET-259.

Logging via UDP

Apache log4net™ can be configured to log messages via UDP in such a way that Chainsaw can receive and display them.

log4net UDP Configuration

Configure log4net to use a UdpAppender with the following config snippet:

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
    <remoteAddress value="127.0.0.1" />
    <remotePort value="8080" />
    <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
        <locationInfo value="true" />
    </layout>
</appender>

Chainsaw UDP receiver Configuration

Chainsaw should be configured to start a UDPReceiver using the following configuration document:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">    
    <plugin name="UDPReceiver" class="org.apache.log4j.net.UDPReceiver">
        <param name="Port" value="8080" />
    </plugin>    
</log4j:configuration>

Logging to XML file

Chainsaw can also load an XML log file if it is formatted according to the log4j schema. Use the following log4net config to output to file using the log4j schema:

<appender name="FileAppender" type="log4net.Appender.FileAppender">
    <file value="log-file.txt" />
    <appendToFile value="true" />
    <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
        <locationInfo value="true" />
    </layout>
</appender>

To load the file into Chainsaw drag the file into the Chainsaw app and drop it on the tab labeled Drag & Drop log files here.