Java Code Examples for ch.qos.logback.classic.LoggerContext#isStarted()
The following examples show how to use
ch.qos.logback.classic.LoggerContext#isStarted() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLocalDevBimServerStarter.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
/** * Add a file appender to every logger we can find (the loggers should already have been configured via logback.xml) * * @throws IOException */ private void fixLogging(BimServerConfig config) throws IOException { Path logFolder = config.getHomeDir().resolve("logs"); if (!Files.isDirectory(logFolder)) { Files.createDirectories(logFolder); } Path file = logFolder.resolve("bimserver.log"); LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); PatternLayoutEncoder ple = new PatternLayoutEncoder(); ple.setPattern("%date %level [%thread] %logger{10} [%file:%line] %msg%n"); ple.setContext(lc); ple.start(); FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>(); String filename = file.toAbsolutePath().toString(); if (lc instanceof LoggerContext) { if (!lc.isStarted()) { lc.start(); } } System.out.println("Logging to " + filename); fileAppender.setFile(filename); fileAppender.setEncoder(ple); fileAppender.setContext(lc); fileAppender.start(); for (ch.qos.logback.classic.Logger log : lc.getLoggerList()) { if (log.getLevel() != null) { log.addAppender(fileAppender); } } }
Example 2
Source File: JarBimServer.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
/** * Add a file appender to every logger we can find (the loggers should already have been configured via logback.xml) * * @throws IOException */ private void fixLogging(BimServerConfig config) throws IOException { Path logFolder = config.getHomeDir().resolve("logs"); if (!Files.isDirectory(logFolder)) { Files.createDirectories(logFolder); } Path file = logFolder.resolve("bimserver.log"); LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); PatternLayoutEncoder ple = new PatternLayoutEncoder(); ple.setPattern("%date %level [%thread] %logger{10} [%file:%line] %msg%n"); ple.setContext(lc); ple.start(); FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>(); String filename = file.toAbsolutePath().toString(); if (lc instanceof LoggerContext) { if (!lc.isStarted()) { lc.start(); } } System.out.println("Logging to " + filename); fileAppender.setFile(filename); fileAppender.setEncoder(ple); fileAppender.setContext(lc); fileAppender.start(); for (ch.qos.logback.classic.Logger log : lc.getLoggerList()) { if (log.getLevel() != null) { log.addAppender(fileAppender); } } }
Example 3
Source File: WarServerInitializer.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
/** * Add a file appender to every logger we can find (the loggers should already have been configured via logback.xml) * * @throws IOException */ private void fixLogging(BimServerConfig config) throws IOException { Path logFolder = config.getHomeDir().resolve("logs"); if (!Files.isDirectory(logFolder)) { Files.createDirectories(logFolder); } Path file = logFolder.resolve("bimserver.log"); LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); PatternLayoutEncoder ple = new PatternLayoutEncoder(); ple.setPattern("%date %level [%thread] %logger{10} [%file:%line] %msg%n"); ple.setContext(lc); ple.start(); FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>(); String filename = file.toAbsolutePath().toString(); if (lc instanceof LoggerContext) { if (!lc.isStarted()) { lc.start(); } } System.out.println("Logging to " + filename); fileAppender.setFile(filename); fileAppender.setEncoder(ple); fileAppender.setContext(lc); fileAppender.start(); for (ch.qos.logback.classic.Logger log : lc.getLoggerList()) { if (log.getLevel() != null) { log.addAppender(fileAppender); } } }