log4j/log4cxx : exclusive 1 to 1 relation between logger and appender

Posted by Omry on Stack Overflow See other posts from Stack Overflow or by Omry
Published on 2010-04-14T07:52:50Z Indexed on 2010/04/14 8:23 UTC
Read the original article Hit count: 306

Filed under:
|
|
|

Using the xml configuration of log4cxx (which is identical in configuration to log4j). I want to have a certain logger output exclusively to a specific appender (have it the only logger which outputs to that appender).

I found that it's possible to bind a logger to a specific appender like this:

<logger name="LoggerName">
    <level value="info"/>
   <appender-ref ref="AppenderName"/>
</logger>

but it that logger still outputs to the root appender because I have this standard piece in the conf file:

<root>
   <priority value="DEBUG"/>
   <appender-ref ref="OtherAppender"/>
</root>

How can I exclude that logger from the root logger? in other words, how do I configure the log such that all loggers inherit the appenders of the root logger except a specific logger?

© Stack Overflow or respective owner

Related posts about log4cxx

Related posts about log4j