I have several loggers defined and a root section with several appenders, something like:
<logger name="X" level="debug"/>
<logger name="Y" level="trace"/>
<logger name="Z" level="warn">
<appender-ref ref="ALERTS-SYSLOG" />
</logger>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE"/>
<appender-ref ref="BUFFER"/>
<appender-ref ref="SYSLOG"/>
</root>
What I'm trying to accomplish is for the logger named Z to go only to the ALERTS-SYSLOG appender and not all the ones defined in the root section. Is that possible only with configuration on the XML file?
See logback documentation for appender additivity and for additivity configuration. In short, the Z logger should be configured as:
<!-- set the additivity attribute of the Z logger to false -->
<logger name="Z" level="warn" additivity="false">
<appender-ref ref="ALERTS-SYSLOG" />
</logger>
Add an entry in the XML file explicitly for logger Z and with the ALERTS_SYSLOG appender and set the additvity flag to false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With