tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe LEGAY <>
Subject log4j - Class.forname - black magie
Date Wed, 21 Dec 2005 19:26:54 GMT

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 file. But no more 
So As I have no change the, I think it is a tomcat problem.

Tests :

On another computer : installation of tomcat 5.5.12 (+ compat for JRE 
1.4) + modify HelloWorld example code to have trace with log4j.
Call the servlet => Get exception : Class logger (from log4j) is not 
found. OK
Add in apache_tomcat.5.5.12/shared/lib the log4j.jar, call the servlet, 
get the HTML page and the trace into a file. OK

Go back on the first computer :
suppress all log4j.jar into the Tomcat Environment 
Call the servlet => Get the HTML content, No trace, and of course no 
exception ! Why ? Where does tomcat find the log4j.jar ?

Just for fun, I add in my servlet code :

 try {
              l = Class.forName("Logger") ;
         catch (java.lang.ClassNotFoundException ex)
         { reshtml.putString("<p>EX Class not Found </p>") ; }

Call the servlet => Get the HTML content +  EX Class not Found + No 
trace, and of course no exception.
If I replace Logger by a tool class (that I use to generated the HTML 
code), the same exception message, but I see the HTML code, so I see the 
result of the tool class that produces this HTML code.

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 ?
- 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 ?

- 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 ?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message