ZeroConf - Zero Configuration

Apache Chainsaw™ can use ZeroConf to discover advertised appenders and automatically configure a matching receiver, but you must update your configuration in order to advertise your appender via ZeroConf.

If you are using a newer version of log4j (1.2.16 or greater), most of the network-based appenders are capable of advertising their configurations via ZeroConf, but have this capability disabled by default. To advertise an appender via ZeroConf: [[1]] Download JmDNS

  1. Add the jmdns.jar to your application's classpath
  2. Modify your log4j configuration so that the appender is set to advertise its configuration via ZeroConf (by setting the 'advertiseViaMulticastDNS' parameter to 'true')

Here is a complete log4j.xml file that you can use as a base SocketAppender configuration which advertises the appender via ZeroConf:/p

<log4j:configuration debug="false" threshold="debug"  xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="socketAppender" class="org.apache.log4j.net.SocketAppender">
        <param name="Name" value="MySockeAppender" />
        <param name="advertiseViaMulticastDNS" value="true" />
    </appender>
    <!--ROOT Logger-->
    <root>
        <level value="INFO" />
        <appender-ref ref="socketAppender" />
    </root>
</log4j:configuration>

If you are using an older version of log4j (prior to 1.2.16), ZeroConfSocketHubAppender is a ZeroConf-capable appender which is backward compatible with the prior versions of SocketHubAppender and can advertise the appender configuration via ZeroConf:/p [[1]] Download JmDNS

  1. Add the ijmdns.jar/i to your application's classpath
  2. Download log4j ZeroConf extension (provides ZeroConfSocketHubAppender)
  3. Add the log4j-zeroconf.jar to your application's classpath

Here is a complete log4j.xml file that you can use as a base ZeroConfSocketAppender configuration which advertises the appender via ZeroConf:/p

<log4j:configuration debug="false" threshold="debug"  xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="zeroconf" class="org.apache.log4j.net.ZeroConfSocketHubAppender">
        <param name="Name" value="MyZeroConfSockeHubAppender" />
    </appender>
    <!--ROOT Logger-->
    <root>
        <level value="INFO" />
        <appender-ref ref="zeroconf" />
    </root>
</log4j:configuration>

Once you have enabled ZeroConf in your log4j configuration and started your application, you should be able to click on the Zeroconf tab inside Chainsaw and see the advertised appenders listed. If you double click on a row, Chainsaw will automatically connect to your application and start receiving events. You can tick the 'auto-connect' option to have Chainsaw immediately connect as soon as it sees your application started. Great for Dev/QA environment./p

Firewalls Multicast protocols generally don't pass through firewall, so in a production environment Zeroconf won't work./p