Search code examples
javalogbackappender

Make a logger to skip the root section in logback


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?


Solution

  • Add an entry in the XML file explicitly for logger Z and with the ALERTS_SYSLOG appender and set the additvity flag to false.