tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <>
Subject Re: deploy log4j
Date Thu, 09 Dec 2010 20:44:39 GMT

I just wrote a very simple web application (2 JSP files, one servlet) and added 
log4j. I ran this on Linux and Windows/XP with both console and file logging. I 
don't have access to a Windows server platform (all UNIX or Linux) so I cannot 
test there. Note, I'm not running under a security manager, and on Windows/XP 
I'm running with an account that has administrator privileges (I know, I know). 
However, Tomcat is started using the local System account, so its privileges are 
more limited.

I didn't get any errors.

A portion of the file:

### direct log messages to stdout ###
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

The above generates log messages to catalina.out on Linux and stdout_<date>.log 
(in %CATALINA_HOME%\logs) on Windows/XP.

As Chris has pointed out, be careful where you put your log4j jar file. Since 
you're logging for a particular web application, place the log4j jar file in 

I'm not sure what potential classloader issues you will run into if you place 
the log4j jar file in $CATALINA_HOME/lib. Definitely do not place the jar file 
in both $CATALINA_HOME/lib and <Application>/WEB-INF/lib.

. . . . just my two cents.


----- Original Message ----
From: Christopher Schultz <>
To: Tomcat Users List <>
Sent: Thu, December 9, 2010 12:11:26 PM
Subject: Re: deploy log4j

Hash: SHA1


On 12/9/2010 1:55 PM, cpanon wrote:
> Specifically when I deploy
> TC6.0.29
> JRE 6.0.22-b04 
> WEB-INF/classes/)

Where is log4j.jar?

> on Win2KSrv, Win2003Srv, and WinXPP I get 
> java.lang.ClassCastException: 
> org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to 
> org.apache.AnnotationProcessor

What is the rest of the stack trace?

> This is the where the differences in the platforms affects the results with all 
> of the above configs.
> 1.  On Windows2K Server and Windows2003 Server it fails to find the properly 
> configured and located log4j file
> 2.  On WinXPP it works perfectly under production TC 6.0.29, finding the log4j 

> file without error.

You should probably not be using Class.getResourceAsStream, but instead
ServletContext.getResourceAsStream. The latter will always load
resources relative to the webapp instead of potentially randomly for
whatever ClassLoader you happen to stumble across.

Where is the code you originally posted running? In a
ServletContextListener? Where is the class for that listener located?

If you are playing games with .jar files and/or classes in the wrong
place because you want to save disk space or something like that, you
will end up with these weird kinds of errors, and you will probably end
up with enormous memory leaks if you (hot) redeploy your webapp.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


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


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

View raw message