## ZeroConf (Zero Configuration)

One of the hardest parts of any network-based application is configuring which bits connect to what, and how do they connect to each other. Each device that can be connected to already knows the configuration details required to connect to it, but every other device that may wish to connect to it will need to be provided with this information so the connection can be established.

ZeroConf aims to eliminate the time-consuming aspect of connecting devices together. The device broadcasts the configuration details reqired to connect or work with the service over a multicast protocol. You probably already have devices on your local network such as printers that are automatically discovered by your computer.

Zeroconf is an open-standard that many vendors are using to reduce cost of configuration. The JmDNS project is an Apache 2.0 licensed library that implements the ZeroConf protocol. Chainsaw and log4j use JmDNS to broadcast Appender information so that a matching Receiver can be easily created to connect to each other to stream logging messages into Chainsaw.

- http://www.zeroconf.org
- http://jmdns.sf.net

## Interesting... So what do I need to use ZeroConf with Chainsaw & log4j?

Most of the network-based appenders are ZeroConf-capable - all you have to do to use ZeroConf is to download the JmDNS package (at least version 1.0), add the JmDNS jar to your application's classpath, and set the "advertiseViaMulticastDNS" parameter to 'true' for any of the appenders or receivers you want to advertise (most of the time you will want to advertise appenders, so they can be automatically detected by Chainsaw).

Your log4j.xml configuration file could be as simple as this:

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

Once you have started your application using this configuration, from within Chainsaw, the ZeroConf tab will show detected applications. You can simply double click on the detected appender and Chainsaw will connect a Receiver to it. You can even tick the "Auto-Connect" check box, and next time Chainsaw see's this application, it will automatically connect to it.

Most of the network-based Receivers are also ZeroConf capable, giving ZeroConf-aware appenders or applications the ability to discover the receivers and configure appenders to connect to those Receivers.

## Cool... But I have some applications that use log4j 1.2.x. Will it still work?

Yes. We have designed a backward compatible mechanism to expose prior versions of log4j's SocketHubAppender (ZeroConfSocketHubAppender) so that Chainsaw can detect it automatically.

## But... Surely there's a catch?

A small catch. Because it's based on a multicast protocol, routers tend to block these packets, and so it's likely that your production computers, which are usually in a heavily protected network won't be able to broadcast their configuration information. If you have a VPN into this sort of network it is possible that these multicast packets can traverse the network.

## Oh... So is this even useful?

It's extremely useful for development, QA and staging environments. Usually the QA/Staging environment is isolated from your development team, but having them monitor logs from these machines would be handy. Or your QA team may want to copy/paste some ERROR messages from QA/staging to notify the dev team. ZeroConf gives your whole software development team an easy way to get access to your logging events.