Vita Rara: A Life Uncommon

Maven Jetty Plugin Logging Woes


Categories: | | |

My logging issues weren't completely over yesterday. I first adopted the "org.apache.commons.logging.impl.SimpleLog" method in the Jetty plugin, but this still spewed far too many lines of logging in my Struts 2 application. The major culprit was FreeMarker. It logs a tremendous amount of data. Far more than I would ever think the average non-FreeMarker developer would ever need.

So, I decided I needed to go the log4j route, so I could control the levels for the various libraries. I copied the dependencies section as explained on the jetty page. This lead to errors when parsing JSP pages and tags. Something in those dependencies introduced something strange into the Jetty runtime environment. After futzing about for a while, and sleeping on it I decided to just delete the dependencies and still try to use log4j. Lo and behold it worked. I started with the log4j.properties file in /src/main/resources created by the Struts 2 Maven archetype as my starting point, and now I have a finely tuned log4j setup.

log4j.rootLogger = DEBUG, stdout

log4j.category.catalia=INFO
log4j.category.com.opensymphony.webwork=DEBUG
log4j.category.com.opensymphony.sitemesh=INFO
log4j.category.com.opensymphony.xwork2=INFO
log4j.category.freemarker=ERROR
log4j.category.org.apache.struts2=INFO
log4j.category.org.apache=INFO
log4j.category.org.hibernate=INFO
log4j.category.org.hibernate.cfg.annotations=ERROR
log4j.category.org.hibernate.cfg.AnnotationBinder=ERROR
log4j.category.org.hibernate.cfg.Ejb3Configuration=ERROR
log4j.category.org.hibernate.tool=ERROR
log4j.category.org.mortbay=INFO
log4j.category.org.slf4j.impl.JCLLoggerAdapter=INFO
log4j.category.org.springframework=INFO

log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold = DEBUG
log4j.appender.stdout.Target   = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{ABSOLUTE} [%C : %F : %L] : %m%n

This gives me a reasonable level of logging information, without being overwhelming. I can easily turn up the level if I need to, say on org.hibernate, if the need presented itself.