use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project jmxtrans by jmxtrans.
the class TimeBasedRollingKeyOutWriter method buildEncoder.
protected Encoder buildEncoder() {
PatternLayoutEncoder logEncoder = new PatternLayoutEncoder();
logEncoder.setContext(loggerContext);
logEncoder.setPattern(getSettingOutputPattern());
logEncoder.start();
return logEncoder;
}
use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project sonarqube by SonarSource.
the class LogbackHelper method newFileAppender.
public FileAppender<ILoggingEvent> newFileAppender(LoggerContext ctx, Props props, RootLoggerConfig config, String logPattern) {
RollingPolicy rollingPolicy = createRollingPolicy(ctx, props, config.getProcessId().getLogFilenamePrefix());
FileAppender<ILoggingEvent> fileAppender = rollingPolicy.createAppender("file_" + config.getProcessId().getLogFilenamePrefix());
fileAppender.setContext(ctx);
PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder();
fileEncoder.setContext(ctx);
fileEncoder.setPattern(logPattern);
fileEncoder.start();
fileAppender.setEncoder(fileEncoder);
fileAppender.start();
return fileAppender;
}
use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project openhab1-addons by openhab.
the class LoggingPersistenceService method createNewAppender.
protected FileAppender<ILoggingEvent> createNewAppender(String alias) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern(pattern);
encoder.start();
FileAppender<ILoggingEvent> appender = new FileAppender<ILoggingEvent>();
appender.setAppend(true);
appender.setFile(LOG_FOLDER + File.separator + alias + LOG_FILEEXT);
appender.setEncoder(encoder);
appender.setContext(context);
appender.start();
return appender;
}
use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project BIMserver by opensourceBIM.
the class JarBimServer method fixLogging.
/**
* 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);
}
}
}
use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project BIMserver by opensourceBIM.
the class LocalDevBimServerStarter method fixLogging.
/**
* 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);
}
}
}
Aggregations