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.

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

The log4j team has created an additional JAR file that can be added to your existing application to enable ZeroConf configuration. You just need to download the log4j-zeroconf.jar and the JmDNS package (you must use at least version 1.0 of JmDNS) and add both JARs to your application's classpath.

Then change your references from SocketHubAppender to ZeroConfSocketHubAppender. (We recommend you change the 'name' propety from it's default to make it easy for you to use, other wise it's name will appear as the default 'SocketHubAppender').

You're 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.ZeroConfSocketHubAppender">
        <param name="Name" value="MyZeroConfSockeHubAppender" />
    </appender>
    <!--ROOT Logger-->
    <root>
        <level value="INFO" />
        <appender-ref ref="zeroconf" />
    </root>
</log4j:configuration>

Once you have started your application using this new appender, then from within Chainsaw, the ZeroConf tab will show detected applications. You can simply double click on the detected app, 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.

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 log4j 1.2.x SocketHubAppender 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.