Register Logback StatusListener when using custom Logback file
Update `LogbackLoggingSystem` so that the `OnErrorConsoleStatusListener` is also registered when loading a custom Logback configuration file. See gh-43931 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
committed by
Phillip Webb
parent
b9f3d522cf
commit
258eb29978
@@ -10,3 +10,7 @@ logging.structured.format.console=smoketest.structuredlogging.CustomStructuredLo
|
||||
#---
|
||||
spring.config.activate.on-profile=on-error
|
||||
logging.structured.json.customizer=smoketest.structuredlogging.DuplicateJsonMembersCustomizer
|
||||
#---
|
||||
logging.config=classpath:custom-logback.xml
|
||||
spring.config.activate.on-profile=on-error-custom-logback-file
|
||||
logging.structured.json.customizer=smoketest.structuredlogging.DuplicateJsonMembersCustomizer
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="org.springframework.boot.logging.logback.StructuredLogEncoder">
|
||||
<format>ecs</format>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -71,4 +71,11 @@ class SampleStructuredLoggingApplicationTests {
|
||||
assertThat(output).contains("The name 'test' has already been written");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCaptureCustomizerErrorWhenUsingCustomLogbackFile(CapturedOutput output) {
|
||||
SampleStructuredLoggingApplication
|
||||
.main(new String[] { "--spring.profiles.active=on-error-custom-logback-file" });
|
||||
assertThat(output).contains("The name 'test' has already been written");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user