Boris Unckel wrote:

Good Morning,

Philippe LEGAY wrote:
Hello

I succeed by black magie to have log via log4j under tomcat 5.5.9. So when a call my servlet, I have some trace into a file (/tmp/phl.log). I said black magie, because I had a lot of problems to put the log4.jar in the right place.

Now, I have just installed the tomcat 5.5.12, reinstalled by web application and of course the same log4j.properties file. But no more trace. So As I have no change the lo4j.properties, I think it is a tomcat problem.

Properly not.
Questions :
- It seems that Class.forName does not work in tomcat. Why ? bad definition ot the PATH ?
- How to set the PATH for Class.forName  ?
- Where is the log4j.jar ? Or Why does I have no exception ? Is there some cache into the TOMCAT server ?
Problem is Between Chair and Keyboard :
Tomcat load library from folder. This mechanism is different from "java -classpath ...mylib.jar ..." where java load the library mylib.jar.

So When I said I have remove all log4j.jar from the Tomcat Environment, it was not exact, because I had a copy of log4j.jar into test-log4j.jar. And tomcat is able to find the class definition into test-log4j.jar. There is no log4j.jar file, but there is in the PATH .jar that contenst the log4j class definition.

- Is it possible to load by hand log4j (with Class.forName or other mechanism) and then get (How ? ) the path used to get this library ?
You just have to setup the log configuration and classpathes correct, see
below.

- And the main question : How must I configure the tomcat server to have log4j trace into my servlet code ? Which version of log4j (5.2.11, or more ) ? Whee must I put the log4j.jar : tomcat.5.5.12/share/lib ?
Download Log4J (v1.2 or later) and place the log4j jar in
$CATALINA_HOME/common/lib.
Download Commons Logging and place the commons-logging.jar (not
commons-logging-api.jar) in $CATALINA_HOME/common/lib with the log4j jar.
To configure the server globally (not per webapp)
Save log4j.properties  into $CATALINA_HOME/common/classes
Remove any log4j.jar or commons-logging.jar from you webapp to test it.

There are two excellent documentations about the configuration:
http://tomcat.apache.org/tomcat-5.5-doc/logging.html
http://tomcat.apache.org/faq/logging.html
=> RTFM : thanks.

As I just need to log4j my application  :

"You would place a similar log4j.properties file in your web application's WEB-INF/classes folder, and log4j1.2.8.jar into WEB-INF/lib. Then specify your package level logging. This is a basic setup of log4j which does *not* require Commons-Logging, and you should consult the log4j documentation for more options. This page is intended only as a bootstrapping guide."

I do it and no more problem.

There is an other document describing the classloading:
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

Thanks.

thanks for your help, it works perfectly now

Best regards, Happy Christmas
PHL.

Regards


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to