Search in sources :

Example 66 with PatternLayoutEncoder

use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project jmxtrans by jmxtrans.

the class KeyOutWriter method buildEncoder.

protected Encoder buildEncoder() {
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern(logPattern);
    encoder.start();
    return encoder;
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder)

Example 67 with PatternLayoutEncoder

use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project TOSCAna by StuPro-TOSCAna.

the class PersistentAppender method setupLayout.

private void setupLayout(LoggerContext lc) {
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern(PATTERN_LAYOUT);
    ple.setContext(lc);
    ple.start();
    setEncoder(ple);
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder)

Example 68 with PatternLayoutEncoder

use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project hub-detect by blackducksoftware.

the class DiagnosticLogger method addAppender.

private FileAppender<ILoggingEvent> addAppender(final String file) {
    final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    final PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern("%date %level [%file:%line] %msg%n");
    ple.setContext(lc);
    ple.start();
    FileAppender<ILoggingEvent> appender;
    appender = new FileAppender<>();
    appender.setFile(file);
    appender.setEncoder(ple);
    appender.setContext(lc);
    appender.start();
    final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(LOGBACK_LOGGER_NAME);
    logbackLogger.addAppender(appender);
    logbackLogger.setLevel(Level.ALL);
    return appender;
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Logger(org.slf4j.Logger) LoggerContext(ch.qos.logback.classic.LoggerContext)

Example 69 with PatternLayoutEncoder

use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project adeptj-runtime by AdeptJ.

the class LogbackManager method newLayoutEncoder.

private PatternLayoutEncoder newLayoutEncoder(String logPattern) {
    PatternLayoutEncoder layoutEncoder = new PatternLayoutEncoder();
    layoutEncoder.setContext(this.loggerContext);
    layoutEncoder.setPattern(logPattern);
    layoutEncoder.setCharset(UTF_8);
    layoutEncoder.start();
    return layoutEncoder;
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder)

Aggregations

PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)69 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)46 LoggerContext (ch.qos.logback.classic.LoggerContext)39 FileAppender (ch.qos.logback.core.FileAppender)21 Logger (ch.qos.logback.classic.Logger)20 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)20 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)18 TimeBasedRollingPolicy (ch.qos.logback.core.rolling.TimeBasedRollingPolicy)13 File (java.io.File)10 Test (org.junit.Test)10 Logger (org.slf4j.Logger)9 SizeBasedTriggeringPolicy (ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy)6 Appender (ch.qos.logback.core.Appender)5 FixedWindowRollingPolicy (ch.qos.logback.core.rolling.FixedWindowRollingPolicy)5 Path (java.nio.file.Path)5 OutputStreamAppender (ch.qos.logback.core.OutputStreamAppender)4 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)3 SyslogAppender (ch.qos.logback.classic.net.SyslogAppender)3 RollingPolicy (ch.qos.logback.core.rolling.RollingPolicy)3 Encoder (ch.qos.logback.core.encoder.Encoder)2