|
|
|
|
@ -250,20 +250,29 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
@@ -250,20 +250,29 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) { |
|
|
|
|
List<Status> statuses = loggerContext.getStatusManager().getCopyOfStatusList(); |
|
|
|
|
StringBuilder errors = new StringBuilder(); |
|
|
|
|
for (Status status : statuses) { |
|
|
|
|
List<Throwable> suppressedExceptions = new ArrayList<>(); |
|
|
|
|
for (Status status : loggerContext.getStatusManager().getCopyOfStatusList()) { |
|
|
|
|
if (status.getLevel() == Status.ERROR) { |
|
|
|
|
errors.append((errors.length() > 0) ? String.format("%n") : ""); |
|
|
|
|
errors.append(status.toString()); |
|
|
|
|
if (status.getThrowable() != null) { |
|
|
|
|
suppressedExceptions.add(status.getThrowable()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (errors.length() > 0) { |
|
|
|
|
throw new IllegalStateException(String.format("Logback configuration error detected: %n%s", errors)); |
|
|
|
|
if (errors.length() == 0) { |
|
|
|
|
if (!StatusUtil.contextHasStatusListener(loggerContext)) { |
|
|
|
|
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!StatusUtil.contextHasStatusListener(loggerContext)) { |
|
|
|
|
StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext); |
|
|
|
|
IllegalStateException ex = new IllegalStateException( |
|
|
|
|
String.format("Logback configuration error detected: %n%s", errors)); |
|
|
|
|
for (Throwable suppressedException : suppressedExceptions) { |
|
|
|
|
ex.addSuppressed(suppressedException); |
|
|
|
|
} |
|
|
|
|
throw ex; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext, |
|
|
|
|
|