From 5eb9cd012c96639a9d202accb15817a2e9e22f4e Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 25 Jun 2015 12:37:56 -0700 Subject: [PATCH] Report logback errors in the exception Update LogbackLoggingSystem to include status errors in the exception rather than using `System.err`. Also perform additional cleanup in an attempt to fix CI build failures. Fixes gh-3309 --- .../logging/logback/LogbackLoggingSystem.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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