We are using Spring Boot and are including org/springframework/boot/logging/logback/base.xml in our logback-spring.xml file. I need to override root logger to exclude/disable/override appenders declared in included file, in particular a CONSOLE appender (well, and remove FILE appender).
I've tried declaring a root logger in logback-spring.xml with my own CONSOLE appender, but that only duplicates the output. I've tried declaring an empty root logger (to set a different logging level) and a new appender with the same name as included one ("CONSOLE"), but that is misleading (as root logger is empty) and still does not remove FILE appender.
Misleading version of logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<!-- bunch of loggers -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
<root level="ERROR">
</root>
</configuration>
What I would expect is something like this:
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="CUSTOM-CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
<root level="ERROR">
<appender-ref ref="CUSTOM-CONSOLE"/>
</root>
And then included CONSOLE and FILE appenders are not used.
Or maybe re-declaring some dummy/no-op CONSOLE and FILE appenders to override included configuration.
EDIT: My question is about appenders inherited from included file hence suggestions in Can I disable an appender in logback? don't really address the issue.