Reputation: 33706
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?
Upvotes: 0
Views: 1061
Reputation: 32144
You use the following piece of configuration for this:
<logger name="TRACER" additivity="false">
<level value="Debug" />
<appender-ref ref="DebugAppender" />
</logger>
All loggers with a name that starts with TRACER
will log to the appender DebugAppender
. For more info, check here or here.
Additivity="false" means messages to this logger will not propogate up the loggers hierarchy so it will not print anything to the root logger.
Upvotes: 4