Log4j based logging in Tomcat 6

14.06.2008 by Dirk Olmes

My favourite annoyance in Tomcat is its logging to the ever-growing, never-rotated catalina.out.

The Tomcat logging setup instructions already contain a description what to do to make Tomcat log through log4. This is definitely a step in the right direction. Tomcat’s logging is properly separated from each webapp’s logging and only output written to System.out will end up in catalina.out.

For hosting third party jars I originally also wanted a mechanism that caputres System.out and System.err and pipes it through commons-logging also. This is to avoid that some misbehaving webapp fills up catalina.out again.

After a lot of poking around with commons-logging, the package rewritten commons-logging called Juli in Tomcat and a simple sample webapp that writes to System.out I came to the conclusion that the best you can get is what’s described in Tomcat’s logging setup.

Since Tomcat has code in place to redirect System.out and System.err to catalina.out, there is no easy way to do custom commons-logging initialization after Tomcat redirected System.out and System.err.


Comments

There are no comments yet.

Leave a comment
Your name:
Comment: