tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Hansen <joe.hansen...@gmail.com>
Subject Re: Log4j logging doesn't work when a web application is moved outside Tomcat/webapps directory
Date Tue, 04 May 2010 23:55:07 GMT
This thread has grown too long. For anyone following this thread,
here's the summary:

Two web applications, each with a Virtual Host entry in server.xml file.
Tomcat/webapps-abc
Tomcat/webapps-xyz

These two web applications have different log4j.properties files.
These log4j property files log to different log files
(Tomcat/logs/abc.log and Tomcat/logs/xyz.log).
Tomcat/webapps-abc/ROOT/WEB-INF/classes/log4j.properties
Tomcat/webapps-xyz/ROOT/WEB-INF/classes/log4j.properties

The web applications abc and xyz using Java Commons Logging API (Log
and LogFactory classes) to perform logging.

Scenario 1:
log4j.jar is in Tomcat/lib directory
log4j.jar is NOT in WEB-INF/lib directories

Result:
abc webapp's log entries are written to xyz.log file


Scenario 2:
log4j.jar is NOT in Tomcat/lib directory
log4j.jar is in WEB-INF/lib directories

Result:
ClassNotFoundError in Tomcat/logs/catalina.log files


Scenario 3:
log4j.jar is in Tomcat/lib directory
log4j.jar is in WEB-INF/lib directories

Result:
Empty abc.log and xyz.log files.


Here's the relevant portion of the webapps-abc/ROOT/WEB-INF/web.xml file:
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/log4j.properties</param-value>
	</context-param>
	<context-param>
		<param-name>log4jExposeWebAppRoot</param-name>
		<param-value>false</param-value>
	</context-param>
	<listener>
    	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  	</listener>


 webapps-xyz/ROOT/WEB-INF/web.xml file looks just the same

/* webapps-abc/ROOT/WEB-INF/classes/log4j.properties */
log4j.rootLogger=INFO, A2
log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d{yyyy MMM dd / HH:mm:ss}
%-5p - [%c] : %m %n
log4j.appender.A2.File=c:/Tomcat6/logs/abc.log
log4j.appender.A2.MaxFileSize=100KB
log4j.appender.A2.MaxBackupIndex=4


/* webapps-xyz/ROOT/WEB-INF/classes/log4j.properties */
log4j.rootLogger=INFO, A1
log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{yyyy MMM dd / HH:mm:ss}
%-5p - [%c] : %m %n
log4j.appender.A1.File=c:/Tomcat6/logs/xyz.log
log4j.appender.A1.MaxFileSize=100KB
log4j.appender.A1.MaxBackupIndex=4

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


Mime
View raw message