Search code examples
javalog4j2zeroconfapache-chainsaw

log4j2 to chainsaw not working - nothing shows up in the 'Zeroconf' tab of Chainsaw


I am trying to to use Chainsaw to view my application's logger events but there is nothing showing up under the 'Zeroconf' tab in chansaw.

I've followed Scott's guide in log4j2 to chainsaw hello world not working… what am I doing wrong? - but no luck. I was going to comment on that question asking how teryet got it working in the end, but as my reputation is below 50, the site didn't allow me.

Environment
OS: OSX Mavericks
IDE: Netbeans 8.0 (Build 201403101706)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
log4j: 2.0rc1
Chainsaw: downloaded the latest DMG from http://people.apache.org/~sdeboy/

Things I've made sure
- included jmdns.jar in the classpath of my application
- Used PatternLayout in my config log4j.xml - Ensure advertiser URL has three slashes

My log4j.xml config file

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration status="OFF" advertiser="multicastdns">
        <appenders>
            <Console name="Console" target="SYSTEM_OUT">
              <PatternLayout pattern="%date{ABSOLUTE} [%thread] %logger{3}.%style{%method}{Blue}%style{(line%line)}{Red}%X %highlight{%-5level} - %msg%n%xEx"/>
            </Console>
            <RollingFile name="RollingFile" fileName="../logs/POS.log" filePattern="../logs/$${date:yyyy-MM}/POS-%d{yyyyMMdd-HHmmss}.log">
                <PatternLayout pattern="%date{ABSOLUTE} [%thread] %logger{3}.%style{%method}{Blue}%style{(line%line)}{Red}%X %highlight{%-5level} - %msg%n%xEx"/>
                <Policies>
                    <OnStartupTriggeringPolicy/>
                    <TimeBasedTriggeringPolicy/>
                </Policies>
            </RollingFile> 
            <File name="testFile" fileName="../logs/POS2.log" bufferedIO="false" advertiseURI="file:///localhost/Users/arthurhsieh/Documents/NetBeansProjects/AES/logs/POS2.log" advertise="true">
                <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %m%n"/>
            </File>
        </appenders>
        <loggers>
            <root level="all"> <!-- <root level="trace"> -->
                <appender-ref ref="Console"/>
                <appender-ref ref="RollingFile"/>
                <appender-ref ref="testFile" />
            </root>
        </loggers>
    </configuration>

I can see logger events in the POS2.log file though.

Thanks in advance for any help/guidances. Cheers.


Solution

  • My issue went away after I restarted my system, i.e., Chainsaw is working and i can view my logs by connecting through the Zeroconf tab.

    My guess is this is an Apple OS issue rather than Chainsaw itself.