tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Robert <arob...@cogsci.ucsd.edu>
Subject How to approximate tomcat-5.0/4.x/3.x logging in 5.5?
Date Tue, 01 Mar 2005 23:18:49 GMT
I'm having trouble approximating the earlier tomcat per-context  
<Logger> functionality using log4j under tomcat-5.5.  Basically, I  
would like to have one file coming out under $CATALINA_BASE/logs/ per  
web application context.  This appears to be no longer possible through  
ServletContext.log().  So I tried using log4j:

1) put log4j.jar, commons-logging.jar in common/lib AND  
webapps/*/WEB-INF/lib
2) put log4j.properties in common/classes AND webapps/*/WEB-INF/classes

However, I can't seem to find the right combination of log4j.properties  
lines, or maybe I'm trying something impossible.  (I can't find good  
docs on the uses of log4j.properties when used inside the hierarchical  
classloading context that tomcat provides.)  What keeps happening is  
that the webapp's log statements keep going into the global tomcat log.  
  Would I be better off with JDK logging instead?

common/classes/log4j.properties
-------------------
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

#log4j.logger.org.apache.catalina			info, R
#log4j.logger.org.apache.catalina.session		info, R
#log4j.logger.org.apache.catalina.session.ManagerBase	info, R

log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhos 
t]=info, R
-------------------

webapp/*/classes/log4j.properties
-------------------
# is this necessary?  tried with and without...
log4j.rootLogger		info, A1

log4j.category.com.foo	, A1
log4j.appender.A1		org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.File		${catalina.base}/logs/bar.log
log4j.appender.A1.MaxFileSize	10MB

log4j.appender.A1.MaxBackupIndex	10
log4j.appender.A1.layout		org.apache.log4j.PatternLayout
log4j.appender.A1.Append	true

log4j.appender.A1.layout.ConversionPattern	%p %t %c - %m%n

log4j.logger.com.foo 	info, A1
-------------------

Code in webapp:
-------------------
Logger logger = Logger.getLogger("com.foo");
logger.info("bar");
-------------------

Any help appreciated..


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message