More logging in Tomcat 5.5+


If you’re trying to deploy a war under Tomcat and it isn’t going like it should be, the first thing you do is look in the console if you ran it from a console, or the log files in Tomcat’s homefolder otherwise. Now this provides you with some details as to why something went wrong, but there is the chance that de application itself is throwing exceptions unlogged which are caught by Tomcat. Those are not logged by default by Tomcat! To log these as well, you’ll need to utilize log4j.

There are two steps to get logs through log4j in Tomcat. One, add the following to {tomcat.home}commonclasses. Two, add the log4j and commons-logging jars to {tomcat.home}commonlib.

Here’s the content for

Here are the jars that worked for me in Tomcat 5.5.27:

There is one drawback to logging to a specific file though. I recon this is because Tomcat is trailing its own logfile into the console, which we have exempted by using our own logfile. The trouble is that Tomcat creates dynamic log files with a date, so we can’t easily just use that logfle for Tomcat to pickup on. Then again, maybe Tomcat is logging to a dynamic logfile as well as the console… I haven’t explored these possibilities.

For some more indepth information I found this article on Tomcat 5.5 logging, and here some of Apache’s own view on Tomcat logging.


Leave a Reply