[BlogEntry] Display source line numbers in Chainsaw with Log4j

0

This is the single most difficult piece of information to find on all the web.

Lemme see, what did I Google for?

  • SocketAppender layout
  • chainsaw ConversionPattern
  • source line number log4j
  • chainsaw location line number
  • jakarta apache commons-logging log4j chainsaw layout please oh please show me my freaking line numbers

I'm not sure why this is the most elusive tidbit of information on the face of the earth, but I'm going to open the kimono and let you in on the secret…

log4j.appender.chainsaw=org.apache.log4j.net.SocketAppender
log4j.appender.chainsaw.RemoteHost=localhost
log4j.appender.chainsaw.Port=4445
log4j.appender.chainsaw.locationInfo=true

Can I tell you how many variations on the ConversionPattern I tried? It's in the dozens. None of them worked.

log4j.appender.chainsaw.layout.ConversionPattern=%d{DATE} [%-5p] %c {%F:%L} - %m%n
log4j.appender.chainsaw.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.chainsaw.layout.ConversionPattern=%d [%t] %-5p %c {%F:%L} - %m%n
log4j.appender.chainsaw.layout.ConversionPattern=%d [%t] (%F:%L) %-5p %c - %m%n

Pretty sick when you find out all you need is locationInfo=true.

This is why I'm JCranky.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge