You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rob van der Leek <ro...@ricardis.tudelft.nl> on 2005/07/14 11:08:51 UTC

Appenders at different log levels for a single logger

Hi list,

How can I define appenders at different log levels for the same logger?  
For instance, what if I want to route all ERROR-level messages to an 
error logfile and all other messages to a different logfile.

I'd hoped something like this would be possible:

log4j.rootLogger=DEBUG, logfile
log4j.rootLogger=ERROR, errorlog

log4j.appender.logfile=org.apache.log4j.RollingFileAppender 
log4j.appender.logfile.File=logfile.log 
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 
log4j.appender.logfile.layout.ConversionPattern=%d [%t:%L] %-6p %c - %m%n 

log4j.appender.errorlog=org.apache.log4j.RollingFileAppender 
log4j.appender.errorlog.File=error.log 
log4j.appender.errorlog.layout=org.apache.log4j.PatternLayout 
log4j.appender.errorlog.layout.ConversionPattern=%d [%t:%L] %-6p %c - 
%m%n 

Unfortunately it seems that this configuration only routes ERROR-level 
messages to the errorlog and discards all other messages.

Best regards,
-- 
Rob van der Leek                |     rob(at)ricardis(dot)tudelft(dot)nl

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


Re: Appenders at different log levels for a single logger

Posted by Rob van der Leek <ro...@ricardis.tudelft.nl>.
On Thu (Jul 14) at 09:34, Philip Kaplan wrote:
> Your second rootLogger entry is overriding your first.  Keep the root
> logger set at debug and place both appenders there...and then set the
> threshold values on each of the loggers to DEBUG and ERROR
> respectively.
> 
> log4j.appender.logfile.Threshold=DEBUG
> log4j.appender.errorlog.Threshold=ERROR

Thanks Philip! I suspected I was overriding and not extending the 
logger, these attributes work fine.

Regards, Rob

-- 
Rob van der Leek                |     rob(at)ricardis(dot)tudelft(dot)nl
Ricardishof 71-A                |          http://www.robvanderleek.info
2614 JE Delft, The Netherlands    
+31 (0)6 155 244 60                

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


Re: Appenders at different log levels for a single logger

Posted by Philip Kaplan <ph...@gmail.com>.
Your second rootLogger entry is overriding your first.  Keep the root
logger set at debug and place both appenders there...and then set the
threshold values on each of the loggers to DEBUG and ERROR
respectively.

log4j.appender.logfile.Threshold=DEBUG
log4j.appender.errorlog.Threshold=ERROR


pK.





On 7/14/05, Rob van der Leek <ro...@ricardis.tudelft.nl> wrote:
> Hi list,
> 
> How can I define appenders at different log levels for the same logger?
> For instance, what if I want to route all ERROR-level messages to an
> error logfile and all other messages to a different logfile.
> 
> I'd hoped something like this would be possible:
> 
> log4j.rootLogger=DEBUG, logfile
> log4j.rootLogger=ERROR, errorlog
> 
> log4j.appender.logfile=org.apache.log4j.RollingFileAppender
> log4j.appender.logfile.File=logfile.log
> log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
> log4j.appender.logfile.layout.ConversionPattern=%d [%t:%L] %-6p %c - %m%n
> 
> log4j.appender.errorlog=org.apache.log4j.RollingFileAppender
> log4j.appender.errorlog.File=error.log
> log4j.appender.errorlog.layout=org.apache.log4j.PatternLayout
> log4j.appender.errorlog.layout.ConversionPattern=%d [%t:%L] %-6p %c -
> %m%n
> 
> Unfortunately it seems that this configuration only routes ERROR-level
> messages to the errorlog and discards all other messages.
> 
> Best regards,
> --
> Rob van der Leek                |     rob(at)ricardis(dot)tudelft(dot)nl
> 
> ---------------------------------------------------------------------
> 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