cpannon, 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 log4j.properties file: ### direct log messages to stdout ### log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 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 <Application>/WEB-INF/lib. 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. /mde/ ----- Original Message ---- From: Christopher Schultz <ch...@christopherschultz.net> To: Tomcat Users List <users@tomcat.apache.org> Sent: Thu, December 9, 2010 12:11:26 PM Subject: Re: deploy log4j -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 cpannon, On 12/9/2010 1:55 PM, cpanon wrote: > Specifically when I deploy > TC6.0.29 > JRE 6.0.22-b04 > log4j.properties(in 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0BN+4ACgkQ9CaO5/Lv0PDQ/QCeMlJ4/UR4drhlwuCVkrjpr3Vd e+8AoJBPGP5PciaW6x34ryk6yrhVQuQY =HaTr -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org