logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bender Heri" <HBen...@Ergonomics.ch>
Subject RE: logger and appender level conflicts
Date Mon, 17 Jul 2006 09:30:32 GMT
I would suggest following:

PackageAppender (threshold DEBUG) 
   + Filter: DENY = (event.getLoggerName() eq. "com.package.class2" )
                    and
                    (event.getLevel() = DEBUG)
DebugAppender (threshold DEBUG)

Logger "com.package" with appender PackageAppender, inherited=true
RootLogger with DebugAppender

I am not shure if the event.getLoggerName() returns the configured logger name or the name
which you gave when getting the Logger. The solution above can be used if the second is true.
Else you have to define two loggers:

Logger "com.package.class1" with appender PackageAppender, inherited=true
Logger "com.package.class2" with appender PackageAppender, inherited=true

The problem with filters is that it has three return values: DENY, NEUTRAL, ACCEPT. If you
use more than one filter on an appender you have to watch the order of declaration. DENY and
ACCEPT are absolute, means the following filter is not asked anymore. Only NEUTRAL will also
ask the next filter in the chain.

Heri



> -----Original Message-----
> From: James Stauffer [mailto:stauffer.james@gmail.com]
> Sent: Friday, July 14, 2006 1:16 AM
> To: Log4J Users List
> Subject: logger and appender level conflicts
> 
> 
> How can I setup logging for the following?
> com.package.class1 debug to PackageAppender
> com.package.class2 info to PackageAppender
> root debug to DebugAppender (including all messages from com.package)
> 
> Because PackageAppender needs to get debug messsages I can't set the
> threshold.  Therefore I should set the level on com.package.class2 to
> info.  But that will prevent debug messages from com.package.class2
> from going to DebugAppender.
> 
> The only idea I have is to is to make 2 pacakge appenders (one with an
> info threshold) and make them both SocketAppenders so the receiver can
> write logs from those 2 appenders to 1 file.  Would it be easier to
> use an appender filter for this?
> 
> -- 
> James Stauffer
> Are you good? Take the test at http://www.livingwaters.com/good/
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message