logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Redl <wasti.r...@gmx.net>
Subject Sharing appender parameters
Date Fri, 10 Nov 2006 13:32:00 GMT
Hi,

I've got Tomcat 5.5 set up to use Log4j for logging. (I'm more
comfortable with that than JULI.)

In short, I want one log file per vhost. My current system is rather
crude, I think: have one RollingFileAppender per vhost, and the logger
for that vhost referring to this appender:

log4j.rootLogger=WARN, 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.core.ContainerBase.[Catalina].[localhost]=INFO,
localhost
log4j.appender.localhost=org.apache.log4j.RollingFileAppender
log4j.appender.localhost.File=${catalina.base}/logs/localhost.log
log4j.appender.localhost.MaxFileSize=10MB
log4j.appender.localhost.MaxBackupIndex=10
log4j.appender.localhost.layout=org.apache.log4j.PatternLayout
log4j.appender.localhost.layout.ConversionPattern=%p %t %c - %m%n

log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[www.tuxcat.local]=INFO,
tuxcat
log4j.appender.tuxcat=org.apache.log4j.RollingFileAppender
log4j.appender.tuxcat.File=${catalina.base}/logs/tuxcat.log
log4j.appender.tuxcat.MaxFileSize=10MB
log4j.appender.tuxcat.MaxBackupIndex=10
log4j.appender.tuxcat.layout=org.apache.log4j.PatternLayout
log4j.appender.tuxcat.layout.ConversionPattern=%p %t %c - %m%n

log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[www.sciencemapper.local]=INFO,
sciencemapper
log4j.appender.sciencemapper=org.apache.log4j.RollingFileAppender
log4j.appender.sciencemapper.File=${catalina.base}/logs/sciencemapper.log
log4j.appender.sciencemapper.MaxFileSize=10MB
log4j.appender.sciencemapper.MaxBackupIndex=10
log4j.appender.sciencemapper.layout=org.apache.log4j.PatternLayout
log4j.appender.sciencemapper.layout.ConversionPattern=%p %t %c - %m%n


As you can see, most of this stuff is constantly duplicated: the
appender class, max file size and backup index, and the layout. The only
thing that changes between appenders is the file name.

Is there a way to make this simpler? Either by having a single appender
that switches file name depending on the logger that calls it (unlikely
that this is possible) or by having appender defaults/prototypes so I
don't have to repeat the configuration all the time?

If that's not possible in 1.2, will it be in 1.3's XML configuration?
(Can't use 1.2's XML configuration with Tomcat's vhost loggers.) Would
it be too late for a feature request?

Sebastian Redl


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


Mime
View raw message