Hi Mark Thank you for the extensive effort in response. However it gets curiouser and curiouser.
Specifically when I deploy TC6.0.29 JRE 6.0.22-b04 log4j.properties(in WEB-INF/classes/) # Set root logger level to DEBUG and its only appender to A1. log4j.rootLogger=WARN, A1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x %M - %m%n on Win2KSrv, Win2003Srv, and WinXPP I get java.lang.ClassCastException: org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor which if "fixed" by this line in context.xml <Loader delegate="true"/> 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. Any ideas? ________________________________ From: Mark Eggers <its_toas...@yahoo.com> To: Tomcat Users List <users@tomcat.apache.org> Sent: Thu, December 9, 2010 1:06:08 AM Subject: Re: deploy log4j You don't say the following: Tomcat version JRE/JDK version Platform (OS and version) That being said, I use log4j (with or without Apache commons logging) for nearly every web application I run on Tomcat. Short answer: You don't manually read in your properties file with log4j. Read a tutorial on log4j for a more complete explanation. What follows below is an overview. Please refer to the log4j documentation, the log4j javadocs, and tutorials around the Internet for a more complete discussion. Code: In each class that you want to use logging, add the following: package foo; // replace with your package name import org.apache.log4j.Logger; public class MyFoo { // replace with your class name private static final Logger log = Logger.getLogger(MyFoo.class); // note 1 /* * rest of class including log.xxxx("message") where xxxx is a level */ } note 1: While it is traditional that one uses getLogger(MyFoo.class), which is shorthand for getLogger(clazz.getName()), you can also name your loggers with any legal string. See the javadoc for more information. Properties File: In your properties file, you'll need appenders as well individual lines for non-default logging levels for each logger name. ### direct messages to file foo.log ### log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=${catalina.home}/logs/foo.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n # default logging level log4j.rootLogger=warn, file # logging for foo.MyFoo - name matches the logger name log4j.logger.foo.MyFoo.type=info Since there is only a file listed in the appenders, then that's where the logging will go. Note that ${catalina.home} was used for logging. This should probably be ${catalina.base} just in case more than one copy of Tomcat is run from a base installation (see RUNNING.txt). This is a handy way of storing log files. If you're doing some in-IDE testing where ${catalina.home} or ${catalina.base} is not set, then hopefully your IDE will let you pass in a Java parameter. Just set -Dcatalina.home=<some-place> (or -Dcatalina.base=<some-place>) while testing. Application Structure: Properties file Package up the application so that log4j.properties gets placed in WEB-INF/classes/log4j.properties. Log4j looks for the properties file in the classpath. Placement in your IDE's project depends on how your IDE packages files. Log4j library Package up the application so that log4j-1.2.15.jar (or whatever version you are using) gets placed in WEB-INF/lib/log4j-1.2.15.jar. Placement in your IDE's project depends on how your IDE packages files. . . . . just my two cents. /mde/ ----- Original Message ---- From: cpanon <cpa...@yahoo.com> To: Tomcat <users@tomcat.apache.org> Sent: Wed, December 8, 2010 8:23:46 PM Subject: deploy log4j Hello I have an app that work perfectly in my IDE(JBuilder05, yes I know but it work fine), but on deployment I believe it is not reading the log4j with this error: java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Unknown Source) followed by log4j:WARN No appenders could be found for logger I am loading the prop file with this(that works in the IDE) java.util.Properties props = new java.util.Properties(); try { props.load(getClass().getResourceAsStream("/log4j.properties")); } catch (IOException ex) { } PropertyConfigurator.configure(props); //ver03_lfj.setLevel(Level.DEBUG); ver03_lfj.debug("yippie"); --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org