<?xml version="1.0" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. 
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with 
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document>

    <properties>
        <author email="rongrabowski at yahoo dot com">Ron Grabowski</author>
        <author email="nicko at apache dot org">Nicko Cadell</author>
        <title>Apache log4net: How To view logging events using Apache log4j Chainsaw</title>
    </properties>

    <meta name="keywords" content="chainsaw log4net, log4net" />

    <body>
        <section id="main" name="How To view logging events using Apache log4j Chainsaw">
            <p>
                Apache log4j&#x2122; includes <a href="http://logging.apache.org/log4j/docs/chainsaw.html">Chainsaw&#x2122;</a>
                a graphical log viewer. 
            </p>
            <p>
                Chainsaw can either receive and display log events in realtime over 
                the network, or it can load a previously created log file.
            </p>
            
            <p>
                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. <br />
                Save one or more of the sample xml config files to your local system and 
                load them when Chainsaw starts.
            </p>
            
            <section id="udp" name="Logging via UDP">
                <p>
                    Apache log4net&#x2122; can be configured to log messages via UDP in such a way that Chainsaw
                    can receive and display them.
                </p>
            
                <section id="udp-conf" name="log4net UDP Configuration">
                    <p>
                        Configure log4net to use a UdpAppender with the following config snippet:
                    </p>

                    <source language="xml"><![CDATA[
<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>]]></source>
                </section>
                
                <section id="udp-chainsaw" name="Chainsaw UDP receiver Configuration">
                    <p>
                        Chainsaw should be configured to start a <c>UDPReceiver</c> using the 
                        following configuration document:
                    </p>

                    <source language="xml"><![CDATA[
<?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>]]></source>
                </section>
                
            </section>
            
            <section id="xml-file" name="Logging to XML file">
                <p>
                    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:
                </p>
                
                <source language="xml"><![CDATA[
<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>]]></source>
                
                <p>
                    To load the file into Chainsaw drag the file into the Chainsaw
                    app and drop it on the tab labeled <i>Drag &amp; Drop log files here</i>.
                </p>        
            </section>
            
        </section>
    </body>
</document>
