You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by William Clar <bc...@seminoleclerk.org> on 2008/11/25 18:33:53 UTC

log4j.properties file in the WEB-INF/classes directory is not being found and loaded

Hello,

 

I'm migrating from Tomcat 5.5.4 to 6.0.18.  On version 5.5.4 we were
able to create two separate log files: catalina.out for System.err, and
traffic.log for the application.  

In version 6.0.18 I'm unable to recreate this scenario.  I've followed
the Tomcat documentation
(http://tomcat.apache.org/tomcat-6.0-doc/logging.html).  I have a
log4j.properties in $CATALINA_HOME/lib which loads the catalina.out file
correctly.  The traffic.log file is the one causing problems.  Per
Tomcat's documentation, I have a log4j.properties file in the
traffic/WEB-INF/classes directory.  This file is not being loaded for
some reason.

What happens is the output from the traffic webapp is showing up in
catalina.out.  The traffic webapp loads and runs without issue, it just
doesn't have its own log file.

I've checked the classpath by turning on debugging and verified the
traffic/WEB-INF/classes directory is in the classpath.   I've also
turned on log4j debugging with -Dlog4j.debug and verified that only the
the catalina.out properties file is loading.

 

I tried configuring the log4j.properties file manually in java, but the
results are the same:  no traffic.log file.  Here's the snippet I used:

 

File logConfFile= new File("/traffic/WEB-INF/classes/log4j.properties");
      
                BasicConfigurator.resetConfiguration();
                if(logConfFile.exists())
                {
 
PropertyConfigurator.configure(logConfFile.getAbsolutePath());
                }
                else
                {
                                BasicConfigurator.configure();
                }



I've researched the source code for log4j and Tomcat but I haven't found
any leads at this point.  Researching the Tomcat bug database turns up
one bug (https://issues.apache.org/bugzilla/show_bug.cgi?id=41996) but
the answers indicate modifying the catalina.properties file.  I'm not
sure I should I do that.

Bill Clar

Java: 1.6.10
System: Fedora, Release 9 (Sulphur)
Kernel Linux 2.6.27.5-37.fc9.i686