logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: Sharing appender parameters
Date Fri, 10 Nov 2006 14:47:10 GMT

It should work to define the common stuff as properties and reference 
them further down the file.  So...




Just apply the same thing to all the other common stuff.  I haven't 
tried this, so I can't guarantee it will work.  I think Log4j only 
looks for properties starting with "log4j.", so Log4j should ignore 
declarations the other properties.  And I'm pretty sure that you can 
refer to a local property in the same property file using the 
${propname} syntax.

I'm not sure what equivalent would be for XML.  You couldn't do this 
other than using system properties with Log4j-1.2.xx.  I'm not sure 
about 1.3.  You might be able to write Joran rules to store the 
properties and use their values later in the file.  Not sure?


At 07:32 AM 11/10/2006, you wrote:
 >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.layout.ConversionPattern=%p %t %c - %m%n
 >log4j.logger.org.apache.catalina=INFO, R
 >log4j.appender.localhost.layout.ConversionPattern=%p %t %c - %m%n
 >log4j.appender.tuxcat.layout.ConversionPattern=%p %t %c - %m%n
 >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

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

View raw message