Chainsaw multiple versions of same log4j -sockethub appender on same tomcat

287 views Asked by At

I have multiple versions of the same application deployed on one tomcat. Both those applications have the same log4j config. So when we use chainsaw only one versions logs show up in chainsaw .

This is what I have in my log4j

log4j.appender.HUB=org.apache.log4j.net.SocketHubAppender
log4j.appender.HUB.port=39867
log4j.appender.HUB.LocationInfo=true
log4j.appender.HUB.Threshold=INFO
log4j.appender.HUB.application=remotehost

Is there a way I keep one log4j file and have port assigned dynamically for chaisaw?

1

There are 1 answers

0
Scott On

If you add JMDNS to your classpath, you can use the ZeroConf support in log4j1.2.17's SocketHubAppender with the latest developer snapshot of Chainsaw in order to 'discover' the sockethubappender configuration in Chainsaw.

  • Download the latest developer snapshot of Chainsaw here: http://people.apache.org/~sdeboy/
  • Pull down JMDNS and add it to your classpath: http://jmdns.sourceforge.net
  • add this to your log4j properties file:
    • log4j.appender.HUB.advertiseViaMulticastDNS=true
  • Change the log4j properties file to define unique 'port' values for each of the deployed app's SocketHubAppender configurations:
    • log4j.appender.HUB.port=(different port for each app)

When you restart your app and Chainsaw, you should have a 'zeroconf' tab in Chainsaw which lists your sockethubappender entries.

Double click on an entry in the ZeroConf tab to open a new tab and start receiving entries from the SocketHubAppender for that app.