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
This commit is contained in:
Phillip Webb 2015-06-25 12:37:56 -07:00
parent 7879743b9f
commit 5eb9cd012c
1 changed files with 13 additions and 11 deletions

View File

@ -125,21 +125,23 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
+ location, ex);
}
List<Status> statuses = context.getStatusManager().getCopyOfStatusList();
if (containsError(statuses)) {
for (Status status : statuses) {
System.err.println(status);
StringBuilder errors = new StringBuilder();
for (Status status : statuses) {
if (status.getLevel() == Status.ERROR) {
errors.append(errors.length() > 0 ? "\n" : "");
errors.append(status.toString());
}
throw new IllegalStateException("Logback configuration error detected");
}
if (errors.length() > 0) {
throw new IllegalStateException("Logback configuration error "
+ "detected: \n" + errors);
}
}
private boolean containsError(List<Status> statuses) {
for (Status status : statuses) {
if (status.getLevel() == Status.ERROR) {
return true;
}
}
return false;
@Override
public void cleanUp() {
super.cleanUp();
getLoggerContext().getStatusManager().clear();
}
@Override