Okay, I've stripped my web app to the bare minimum, and performed exactly the steps described in Tomcat 5.5/Tomcat 6.0 documentation regarding using log4j for logging. Here's more detail, hopefully things will be made clear.
In my web app, I have a single servlet, personal.ExceptionServlet:
Packaged with the servlet in the war file, I've included WEB-INF/lib/log4j-1.2.16.jar, WEB-INF/lib/commons-logging-1.1.1.jar, and WEB-INF/classes/log4j.properties file containing
Now, in my Tomcat 5.5.26 installation, I have as per the
Tomcat 5.5 Logging documentation log4j-1.2.16.jar in $TOMCAT_HOME/common/lib, commons-logging-1.1.1.jar in $TOMCAT_HOME/common/lib, and log4j.properties in $TOMCAT_HOME/common/classes containing
Finally, in my Tomcat 6.0.33 installation, I have as per the
Tomcat 6.0 Logging Documentation log4j-1.2.16.jar in $TOMCAT_HOME/lib, tomcat-juli-adapters.jar from the "extras" directory for the 6.0.33 download dir also in $TOMCAT_HOME/lib, and replaced tomcat-juli.jar in $TOMCAT_HOME/bin with the one from the "extras" directory. I also have a log4j.properties file in $TOMCAT_HOME/lib containing the same as above:
So I deploy my web application into Tomcat 5.5, start it up, and invoke the ExceptionServlet. This produces an exception message and stack dump in ex.info.log:
Now, I stop Tomcat 5.5, copy my web application war file into Tomcat 6.0, start up Tomcat 6.0, invoke the ExceptionServlet again, this time getting the exception message and stack trace in $TOMCAT_HOME/logs/tomcat.log
Same code, different location for the exception message. So where's my mistake? Not using log4j at the moment is a non-starter, nor is upgrading to Tomcat 7. I need Tomcat 6.0 to behave the way Tomcat 5.5 behaved wrt the ServletException logging. Is there something I need to add to my Tomcat log4j.properties? Any insight is greatly appreciated!