[BlogEntry] Display source line numbers in Chainsaw with Log4j


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…


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