I run SpringBoot services on Docker, the Docker daemon will have very high CPU load if it gets huge console log output, so I would like to filter out some log levels for console but keep default settings for file.
Currently I have to write src/main/resources/logback-spring.xml, that's copied from https://github.com/spring-projects/spring-boot/blob/v3.0.0-M4/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- https://github.com/spring-projects/spring-boot/blob/v3.0.0-M4/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/base.xml -->
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}" />
<springProfile name="!(prod | production)">
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
</springProfile>
<springProfile name="prod | production">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>${CONSOLE_LOG_CHARSET}</charset>
</encoder>
</appender>
</springProfile>
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
It's better if we have a new SpringBoot property logging.threshold.APPENDER=LEVEL to control that, so that I don't have to write logback-spring.xml.
Comment From: philwebb
Closing in favor of PR #32076.