use of ch.qos.logback.core.status.StatusListenerAsList in project sling by apache.
the class LogbackManager method configure.
private void configure(ConfiguratorCallback cb) {
long startTime = System.currentTimeMillis();
StatusListener statusListener = new StatusListenerAsList();
if (debug) {
statusListener = new OnConsoleStatusListener();
}
getStatusManager().add(statusListener);
addInfo("Resetting context: " + getLoggerContext().getName());
resetContext(statusListener);
StatusUtil statusUtil = new StatusUtil(getLoggerContext());
JoranConfigurator configurator = createConfigurator();
final List<SaxEvent> eventList = configurator.recallSafeConfiguration();
final long threshold = System.currentTimeMillis();
boolean success = false;
try {
cb.perform(configurator);
if (statusUtil.hasXMLParsingErrors(threshold)) {
cb.fallbackConfiguration(eventList, createConfigurator(), statusListener);
}
addInfo("Context: " + getLoggerContext().getName() + " reloaded.");
success = true;
} catch (Throwable t) {
//Need to catch any error as Logback must work in all scenarios
//The error would be dumped to sysout in later call to Status printer
addError("Error occurred while configuring Logback", t);
} finally {
if (!success) {
cb.fallbackConfiguration(eventList, createConfigurator(), statusListener);
}
getStatusManager().remove(statusListener);
SlingStatusPrinter.printInCaseOfErrorsOrWarnings(getLoggerContext(), resetStartTime, startTime, success);
}
}
Aggregations