diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 6d8dbaa4a9..52a10a8e4e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -125,21 +125,23 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { + location, ex); } List statuses = context.getStatusManager().getCopyOfStatusList(); - if (containsError(statuses)) { - for (Status status : statuses) { - System.err.println(status); - } - throw new IllegalStateException("Logback configuration error detected"); - } - } - - private boolean containsError(List statuses) { + StringBuilder errors = new StringBuilder(); for (Status status : statuses) { if (status.getLevel() == Status.ERROR) { - return true; + errors.append(errors.length() > 0 ? "\n" : ""); + errors.append(status.toString()); } } - return false; + if (errors.length() > 0) { + throw new IllegalStateException("Logback configuration error " + + "detected: \n" + errors); + } + } + + @Override + public void cleanUp() { + super.cleanUp(); + getLoggerContext().getStatusManager().clear(); } @Override