Skip to content

Commit bc19e39

Browse files
committed
Report Logback configuration errors when running in a native image
Closes gh-34315
1 parent 6983850 commit bc19e39

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -207,7 +207,11 @@ private boolean initializeFromAotGeneratedArtifactsIfPossible(LoggingInitializat
207207
stopAndReset(loggerContext);
208208
SpringBootJoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
209209
configurator.setContext(loggerContext);
210-
return configurator.configureUsingAotGeneratedArtifacts();
210+
boolean configuredUsingAotGeneratedArtifacts = configurator.configureUsingAotGeneratedArtifacts();
211+
if (configuredUsingAotGeneratedArtifacts) {
212+
reportConfigurationErrorsIfNecessary(loggerContext);
213+
}
214+
return configuredUsingAotGeneratedArtifacts;
211215
}
212216

213217
@Override
@@ -241,6 +245,10 @@ protected void loadConfiguration(LoggingInitializationContext initializationCont
241245
catch (Exception ex) {
242246
throw new IllegalStateException("Could not initialize Logback logging from " + location, ex);
243247
}
248+
reportConfigurationErrorsIfNecessary(loggerContext);
249+
}
250+
251+
private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) {
244252
List<Status> statuses = loggerContext.getStatusManager().getCopyOfStatusList();
245253
StringBuilder errors = new StringBuilder();
246254
for (Status status : statuses) {

0 commit comments

Comments
 (0)