Adapt to Logback deprecation
This commit also adds a test so that we can catch this problem hopefully sooner in the future. Closes gh-42006
This commit is contained in:
@@ -5,11 +5,11 @@ Default logback configuration provided for import
|
||||
-->
|
||||
|
||||
<included>
|
||||
<conversionRule conversionWord="applicationName" converterClass="org.springframework.boot.logging.logback.ApplicationNameConverter" />
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="correlationId" converterClass="org.springframework.boot.logging.logback.CorrelationIdConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="applicationName" class="org.springframework.boot.logging.logback.ApplicationNameConverter" />
|
||||
<conversionRule conversionWord="clr" class="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="correlationId" class="org.springframework.boot.logging.logback.CorrelationIdConverter" />
|
||||
<conversionRule conversionWord="wex" class="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" class="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
|
||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr(%applicationName[%15.15t]){faint} %clr(${LOG_CORRELATION_PATTERN:-}){faint}%clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
<property name="CONSOLE_LOG_CHARSET" value="${CONSOLE_LOG_CHARSET:-${file.encoding:-UTF-8}}"/>
|
||||
|
||||
@@ -130,6 +130,22 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
|
||||
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
void logbackDefaultsConfigurationDoesNotTriggerDeprecation(CapturedOutput output) {
|
||||
initialize(this.initializationContext, "classpath:logback-include-defaults.xml", null);
|
||||
this.logger.info("Hello world");
|
||||
assertThat(getLineWithText(output, "Hello world")).isEqualTo("[INFO] - Hello world");
|
||||
assertThat(output.toString()).doesNotContain("WARN").doesNotContain("deprecated");
|
||||
}
|
||||
|
||||
@Test
|
||||
void logbackBaseConfigurationDoesNotTriggerDeprecation(CapturedOutput output) {
|
||||
initialize(this.initializationContext, "classpath:logback-include-base.xml", null);
|
||||
this.logger.info("Hello world");
|
||||
assertThat(getLineWithText(output, "Hello world")).contains(" INFO ").endsWith(": Hello world");
|
||||
assertThat(output.toString()).doesNotContain("WARN").doesNotContain("deprecated");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ClassPathOverrides({ "org.jboss.logging:jboss-logging:3.5.0.Final", "org.apache.logging.log4j:log4j-core:2.19.0" })
|
||||
void jbossLoggingRoutesThroughLog4j2ByDefault() {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%p] - %m%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user