Hello, you can specify the logoutput as relative path: instead of log4j.appender.file.File=/var/log/webapp.log to log4j.appender.file.File=logs/webapp.log and link the local file to the desired destination.
regards Leon On Mon, Dec 19, 2011 at 5:54 PM, Simon <spyd...@gmail.com> wrote: > Hi, > > Our webapp is packaged with the log4j framework (1.2.16) and a log4j > configuration that redirect all logs to a file on the server > filesystem. This log file is rotated when it reaches 50M. > > Here is the configuration detail : > > log4j.rootLogger=INFO, file > log4j.appender.file=org.apache.log4j.RollingFileAppender > log4j.appender.file.File=/var/log/webapp.log > log4j.appender.file.MaxFileSize=50000KB > log4j.appender.file.MaxBackupIndex=50 > log4j.appender.file.layout=org.apache.log4j.PatternLayout > log4j.appender.file.layout.ConversionPattern=%d %-5p %c - %m%n > > This configuration file is located inside the webapp.war archive at > /WEB-INF/classes/log4j.properties. > > In our production environment, we started with one tomcat instance and > everything was fine. The tomcat version is 5.5.20 and it is running on > the Oracle JVM 1.6.0_23-b05. > > > Unfortunately, when the infrastructure team added 2 other Tomcat > instances on the same server with the same webapp.war inside, some > logs were lost. The 2 instances are basically a complete copy of the > file tree of the first instance. Thus, there is 3 identical webapps > logging into the same log file simultaneously : > /tomcat/instance-1/webapps/webapp.war => /var/log/webapp.log > /tomcat/instance-2/webapps/webapp.war => /var/log/webapp.log > /tomcat/instance-3/webapps/webapp.war => /var/log/webapp.log > > My hypothesis is that as every webapp log to the same log file from a > different JVM (the tomcat instances), there could be some concurrency > issues when the rolling from log4j occurs !!! > > > I would like that each webapp logs to a particular file without having > a different log4j configuration packaged in the webapp.war archive. My > first idea was to modify the log4j configuration so the webapp will > log to the console (stdout) and then find a way to redirect the stdout > inside a Tomcat instance to a particular file : > /tomcat/instance-1/webapps/webapp.war => stdout => /var/log/webapp-1.log > /tomcat/instance-2/webapps/webapp.war => stdout => /var/log/webapp-2.log > /tomcat/instance-3/webapps/webapp.war => stdout => /var/log/webapp-3.log > > I know i could achieve that with the Resin application server through > the use of the <stdout /> configuration element > (http://caucho.com/resin-4.0/reference.xtp#stdoutlog, > http://caucho.com/resin-4.0/admin/logging.xtp). > > Is there a way to mimic this behaviour in Tomcat ? > > --------------------------------------------------------------------- > 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