Hello dB; This is the step by step actions to configure your log4j logging in one place in Tomcat "lib/log4j.properties"
Actions --------------------- 1- Remove logging.properties from conf/logging.properties 2- Remove tomcat-juli.jar from bin/tomcat-juli.jar 3- Get "tomcat-juli.jar" and "tomcat-juli-adapters.jar" from "http://godel.cs.bilgi.edu.tr/apache/tomcat/tomcat-6/v6.0.26/bin/extras/" or any other place 4- Put "tomcat-juli.jar" to "bin" folder 5- Put "tomcat-juli-adapters.jar" to "lib" folder 6- Download "log4j.jar" and put to "lib" folder 7- Creates a log4j.properties and put it into "lib" folder. Example Configuration: log4j.rootLogger=INFO, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${catalina.base}/logs/tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n //Manager application log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]= DEBUG,B log4j.appender.B=org.apache.log4j.RollingFileAppender log4j.appender.B.File=${catalina.base}/logs/gurkan.log --> Its own log file log4j.appender.B.MaxFileSize=10MB log4j.appender.B.MaxBackupIndex=10 log4j.appender.B.layout=org.apache.log4j.PatternLayout log4j.appender.B.layout.ConversionPattern=%p %t %c - %m%n //Example application log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/examples]= DEBUG,C log4j.appender.C=org.apache.log4j.RollingFileAppender log4j.appender.C.File=${catalina.base}/logs/example.log --> Its own log file log4j.appender.C.MaxFileSize=10MB log4j.appender.C.MaxBackupIndex=10 log4j.appender.C.layout=org.apache.log4j.PatternLayout log4j.appender.C.layout.ConversionPattern=%p %t %c - %m%n This will creates a root logger --> INFO and logs message to tomcat.log. Each web application can override ROOT like I did for manager and examples web applications. I hope it helps :))) --Gurkan ________________________________ From: dB. <dbl...@dblock.org> To: Tomcat Users List <users@tomcat.apache.org> Sent: Fri, June 18, 2010 3:49:03 PM Subject: RE: how can i configure Tomcat's log4j to log in a separate file for each webapp? That's exactly what I am trying to avoid :) I have a lot of web apps and developers that stand on their head for logging. My customers end up finding logs all over the place and enforcing it by convention is getting harder and harder. I'd like to configure logging for them rather than leave logging to their discretion. So I want the centralized log4j configuration that can insert the web app name into the file name that belongs to the tomcat installation. dB. @ dblock.org Moscow|Geneva|Seattle|New York -----Original Message----- From: Erik Bertelsen [mailto:bertelsen.e...@gmail.com] Sent: Friday, June 18, 2010 8:37 AM To: Tomcat Users List Subject: Re: how can i configure Tomcat's log4j to log in a separate file for each webapp? 2010/6/18 dB. <dbl...@dblock.org>: > This question is all over the internet, without a satisfactory answer. > > We have a Tomcat deployment in which we install many web apps. We call this > thing a services host. It has a log4j configuration that forwards logs into a > file. I'd like to change the file pattern to include the name of the webapp, > so that we can get one file per web application. > > > * Is anyone doing that? I do this all the time. For applications using commons-logging, I place commons-logging.jar and log4j.jar in the webapp's WEB-INF/lib directory and log4j.properties in WEB-INF/classes. The same works if slf4j-api and slf4j-log4j12 is used instead of or in addition to commons-logging. I never add jar files used by individual webapps to tomcat's lib or any other directory shared by several webapps. kind regards - Erik --------------------------------------------------------------------- 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