I went through all of these problems myself when I tried to get Log4j working as my system logger in Tomcat 5.0.27. I followed the directions in the FAQ but log4j was not being detected on bootup. I too modified the "catalina.sh" startup script and added the log4j.jar file to the classpath and even added the bin directory to the classpath in order for the log4j.properties file to be "seen" by the class loader. Only then did Log4j work at startup.
However, I had made a fundamental mistake. I eventually did get Log4j to work as others have described using the common/lib and common/classes directories. This morning, I installed a fresh copy of Tomcat 5.0.27 into a temporary directory to see if I could reproduce what I did right and what I did wrong.
The correct way to install Log4j as your Tomcat 5.0 system logger is:
1) Shutdown Tomcat. 2) Install commons-logging.jar into common/lib. 3) Install log4j-1.2.8.jar into common/lib 4) Create an appropriate log4j.properties file in common/classes. 5) Restart Tomcat.
This actually works. The step that I must have missed the first time I tried this is probably a mistake others are making: you MUST install commons-logging.jar into your common/lib directory.
Yes, I know there is a commons-logging-api.jar file in the bin (bootstrap) directory of Tomcat. Leave it there; you can't boot without it. You also can't replace it with a full blown commons-loging.jar file. The commons-logging-api.jar file appears to be a stripped down version of the full commons-logging.jar file which only implements SimpleLog or something like it. Basically, just enough of a logging system to get bootstrapped.
Through some classloading voodoo during bootstrapping, if you have the full commons-logging.jar file in your common/lib directory, it replaces the classes from the commons-logging-api.jar file and will reinitialize the logging system and attempt to locate log4j or whatever other logging system you may be using.
It was due to my own frustrations at getting Log4j working with Tomcat that I wrote the technical tip I posted to this list this weekend:
http://minaret.biz/tips/tomcatLogging.html
I appreciate the fact that someone has added a link from the Tomcat FAQ to this page. Anyone is more than welcome to cut, copy and paste any of my stuff to build a better logging FAQ. If you need any help, let me know.
Best,
Geoff
Shapira, Yoav wrote:
Hi, Hmm, it's possible that now that we've moved Tomcat's bootstrapping code to also use commons-logging, the impl lib is needed on the bootstrap classpath. I'll amend the FAQ entry to also link to this thread and give some though to updating the documentation-proper (as opposed to the FAQ) on this issue.
Yoav Shapira Millennium Research Informatics
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, September 05, 2004 2:13 PM To: [EMAIL PROTECTED] Subject: Log4J in Tomcat 5.0...I don't believe the FAQ
Patrick Burleson wrote about problems in getting Tomcat to use log4j by following the FAQ. I have been struggling the same fight for some time,
but
a hint in one of the recipes finally lead me to the solution.
It is --not-- enough to place log4j-x-x-x.jar in
$CATALINA_HOME/common/lib
and the properties file in .../common/classes.
You --also-- have to place log4j-x-x-x.jar in classpath when starting tomcat.
I did not find a "nice" way of doing this, but appending the path to
log4j-
x-x-x.jar to the line
CLASSPATH="$CLASSPATH":"$CATALINA_HOME"/bin/bootstrap.jar:"$CATALINA_HO
ME"/
bin/c ommons-logging-api.jar
in .../bin/catalina.sh did the trick, i.e. with this change, commons- logging will discover logj4.jar and use it.
It would be nice to be able to supply this extra classpath entry when invoking catalina.sh instead of having to modify the script each time tomcat is updated.
regards Erik Bertelsen
------------------------------------------------- WebMail fra Tele2 http://www.tele2.dk -------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
