use of ch.qos.logback.classic.util.ContextInitializer in project weave by continuuity.
the class ServiceMain method configureLogger.
private void configureLogger() {
// Check if SLF4J is bound to logback in the current environment
ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
if (!(loggerFactory instanceof LoggerContext)) {
return;
}
LoggerContext context = (LoggerContext) loggerFactory;
context.reset();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
try {
File weaveLogback = new File(Constants.Files.LOGBACK_TEMPLATE);
if (weaveLogback.exists()) {
configurator.doConfigure(weaveLogback);
}
new ContextInitializer(context).autoConfig();
} catch (JoranException e) {
throw Throwables.propagate(e);
}
doConfigure(configurator, getLogConfig(getLoggerLevel(context.getLogger(Logger.ROOT_LOGGER_NAME))));
}
use of ch.qos.logback.classic.util.ContextInitializer in project spring-boot by spring-projects.
the class LogbackLoggingSystem method configureByResourceUrl.
private void configureByResourceUrl(LoggingInitializationContext initializationContext, LoggerContext loggerContext, URL url) throws JoranException {
if (url.toString().endsWith("xml")) {
JoranConfigurator configurator = new SpringBootJoranConfigurator(initializationContext);
configurator.setContext(loggerContext);
configurator.doConfigure(url);
} else {
new ContextInitializer(loggerContext).configureByResource(url);
}
}
Aggregations