I'm not sure if this will help, but I run Tomcat6 under on Windows and use the Tomcat Service. The service redirects stdout and stderr to files. For log4j, I simply define a ConsoleAppender and assign it to the root logger, which gets directed to the stdout log file. stdout goes to stdout_[current date].log and stderr goes to stderr_[current date].log without me specifying those log file names. System.out goes to the stdout log file.
Not sure what the equivalent setup would be on a *nix box, but I'm sure there's something similar. Jake On 4/10/2009 2:30 PM, Olexandr Prokhorenko wrote: > Hi, > > I have an application-wide log4j.properties which logs to stdout, with > the config like: > > log4j.rootLogger=WARN, stdout > log4j.appender.stdout=org.apache.log4j.ConsoleAppender > log4j.appender.stdout.layout=org.apache.log4j.PatternLayout > > It sends all mess to catalina.out. However, I want to use log4j for > Tomcat 5.5 logging now. So I configured Tomcat to write WARN to > tomcat.log and eventually I'll want to receive ERROR by email > (org.apache.log4j.net.SMTPAppender or just different file work work just > fine for me). Here's what I've got for conf/log4j.properties (or > common/classes/log4j.properties, as I basically have a symlink). > > log4j.rootLogger=WARN, R > log4j.appender.R=org.apache.log4j.RollingFileAppender > log4j.appender.R.File=${catalina.home}/logs/tomcat.log > log4j.appender.R.MaxFileSize=10MB > log4j.appender.R.MaxBackupIndex=5 > log4j.appender.R.layout=org.apache.log4j.PatternLayout > log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n > > log4j.logger.org.apache.catalina.core=WARN, R > log4j.logger.org.apache.catalina.session=WARN, R > > However, it comes that because of my application(s) write directly to > stdout they don't happen to appear in my server-wide log4j output, their > messages still go to catalina.out. I changed conf/context.xml to > include swallowOutput, but it doesn't seem to be working (at least not > for my stuff): > > <Context swallowOutput="true" /> > > My application(s) still write to catalina.out. What is the best way to > make it do what I want? Thank you. > > P.S. I have more then 20 wars built with log4j.properties which write to > stdout, so changing this piece is pretty unwelcome. ;) I'd be happy to > find some server-wide override tool instead. Sometimes I don't even > know does the application have an explicit stdout output or not. Thank > you. > > --Alexander Prohorenko. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org