db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Guest <robguest2...@yahoo.com>
Subject Tips on fixing broken logging configurations
Date Wed, 07 Apr 2004 16:18:19 GMT
I recently updated some apache libraries, including Torque, and
discovered that when I started Tomcat I got lots of debug messages from
various Commons libraries and Torque. I thought I had the logging
properties setup ok...but alas, no. 
I solved my problem by removing the torque-gen-3.1.jar from my lib
directory. Log4j was using the log4j.properties file from that jar to
configure itself. Here are some tips I discovered along the way that
might help you.
Torque uses commons.logging and will attempt to use log4j if it can
find log4j in the classpath. 
If you want to check what the classpath is use:

If you want to see what Torque will use for its default Log try:
 Log log = LogFactory.getLog("");
 System.out.println("Using Log is " + log.getClass().getName());
(Torque will use SimpleLog if nothing better is found.)

Log4j configures itself when LogManager is used for the first time
(e.g. calling static method LogManager.getLogger()) or when Torque
tries to configure itself. 

Log4j will use the first log4j.properties file it finds in the
classpath, searching in jars and zip files. I've painfully discovered
that even if you think the right log4j.properties file is first in the
path, it may not be the one that wins (maybe this is the IDE's fault)

If you set debugging on in log4j it will tell you what log4.properties
file it is using. However you need to do this before the LogManager
class is used. You can set the debug on with this line:


Of course the prefered method to set debugging on would be to add the
following line to the log4j.properties file:
log4j.debug = true

By doing this you will see what Loggers and Appenders log4j is setting

If you see these lines (e.g. from the log4j.properties file in
torque-gen-3.1.jar) it means that you configured a logger to use an
appender that does not get setup:
log4j:ERROR Could not find value for key
log4j:ERROR Could not instantiate appender named

In the torque-gen-3.1.jar log4j.properties file the rootLogger will use
an appender named torque-gen. This will work because the appender is
configured in this file.
log4j.rootLogger = INFO, torque-gen

The following line will ask to use an appender that is never
log4j.category.org.apache.torque-gen = DEBUG, org.apache.torque.engine

After log4j reads the whole file it processes the properties data and
will report an error when the org.apache.torque.engine appender is not

Rob Guest



Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 

To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message