How to get V2.3 logging working with Tomcat

Problem: Turbine V2.3 logs to the console at DEBUG level. V2.2 logging was pure Log4J. Now there is a "convenience" layer based on commons logging.

a solution appeared in the turbine newsgroup:

To all the followers of the "logging" problem:

Found some insight into this...

Apparently there are several lines of code that attempt to set the System
property for log4j to the following in the configure() method:


Lines approx: 266-270
// Set up Commons Logging to use the Log4J Logging
{{{                                   Log4jFactory.class.getName()); 

This does not work and LogFactory uses the SimpleLogger instead, piping all INFO and above logging statements to the console. I've tried to relocate the code to a static initializer block and that does not work either.

The best workaround I've found so far, if using Tomcat (translate these directions for other containers), is to add the following to the JAVA_OPTS environment variable:
-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4 jFactory

And make sure the Log4J libraries are in the "common" directory for Tomcat.

Keep me posted - I hope this helps those frustrated commons-turbine users out there (smile)

This was posted by Brad Folkens in the Turbine Users List. This excellent post should appear in the How To. I wasted half a day before coming across it.

9th April 2004 malcolm kendall

  • No labels