use of ch.qos.logback.classic.BasicConfigurator in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method resetLogging.
@Before
public void resetLogging() {
LoggerContext loggerContext = ((Logger) LoggerFactory.getLogger(getClass())).getLoggerContext();
loggerContext.reset();
new BasicConfigurator().configure(loggerContext);
}
use of ch.qos.logback.classic.BasicConfigurator in project perun by CESNET.
the class PerunLogbackConfigurator method configure.
@Override
public void configure(LoggerContext loggerContext) {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
String confDir = System.getProperty("perun.conf.custom", "/etc/perun/");
File confFile = Paths.get(confDir, "logback.xml").toFile();
if (confFile.exists()) {
System.out.println("Loading logback config file " + confFile);
try {
// loads logback file
configurator.doConfigure(confFile.toString());
} catch (JoranException e) {
e.printStackTrace();
}
} else {
System.out.println("Loading logback-default.xml file from classpath");
try (InputStream configStream = this.getClass().getResourceAsStream("/logback-default.xml")) {
// loads logback file
configurator.doConfigure(configStream);
configStream.close();
} catch (IOException | JoranException e) {
e.printStackTrace();
System.out.println("Falling back to logback basic configurator");
BasicConfigurator basicConfigurator = new BasicConfigurator();
basicConfigurator.setContext(loggerContext);
basicConfigurator.configure(loggerContext);
}
}
}
use of ch.qos.logback.classic.BasicConfigurator in project spring-boot by spring-projects.
the class SpringBootJoranConfiguratorTests method reset.
@After
public void reset() {
this.context.stop();
new BasicConfigurator().configure((LoggerContext) LoggerFactory.getILoggerFactory());
}
Aggregations