Search in sources :

Example 61 with PatternLayoutEncoder

use of ch.qos.logback.classic.encoder.PatternLayoutEncoder in project TranslateIt-api by zunpiau.

the class LogbackConfig method encoder.

@Bean(initMethod = "start", destroyMethod = "stop")
public static PatternLayoutEncoder encoder(LoggerContext ctx) {
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(ctx);
    encoder.setPattern("%d{yy-MM-dd HH:mm:ss.SSS} [%-5level] [%thread] %logger - %msg%n");
    return encoder;
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) Bean(org.springframework.context.annotation.Bean)

Example 62 with PatternLayoutEncoder

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

the class Log method init.

private void init() {
    opts = NinjaUtils.getOptions(context.getJc(), BaseOptions.class);
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    if (opts.isVerbose()) {
        ple.setPattern("%date [%thread] %-5level \\(%logger{46}\\): %message%n<");
    } else {
        ple.setPattern("%msg%n");
    }
    ple.setContext(lc);
    ple.start();
    ConsoleAppender out = setupAppender("STDOUT", "System.out", lc, setupEncoder(lc));
    ConsoleAppender err = setupAppender("STDERR", "System.err", lc, setupEncoder(lc));
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    if (LogTarget.SYSTEM_OUT.equals(target)) {
        root.addAppender(out);
    } else {
        root.addAppender(err);
    }
    root.setLevel(Level.OFF);
    info = setupLogger(LOGGER_SYS_OUT, opts);
    error = setupLogger(LOGGER_SYS_ERR, opts);
    error.setAdditive(false);
    error.addAppender(err);
}
Also used : BaseOptions(com.evolveum.midpoint.ninja.opts.BaseOptions) PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) ConsoleAppender(ch.qos.logback.core.ConsoleAppender) Logger(ch.qos.logback.classic.Logger) LoggerContext(ch.qos.logback.classic.LoggerContext)

Example 63 with PatternLayoutEncoder

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

the class Log method setupEncoder.

private Encoder setupEncoder(LoggerContext ctx) {
    PatternLayoutEncoder ple = new PatternLayoutEncoder();
    if (opts.isVerbose()) {
        ple.setPattern("%date [%thread] %-5level \\(%logger{46}\\): %message%n");
    } else {
        ple.setPattern("%msg%n");
    }
    ple.setContext(ctx);
    ple.start();
    return ple;
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder)

Example 64 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 65 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)

Aggregations

PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)65 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)44 LoggerContext (ch.qos.logback.classic.LoggerContext)37 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)17 TimeBasedRollingPolicy (ch.qos.logback.core.rolling.TimeBasedRollingPolicy)13 File (java.io.File)10 Test (org.junit.Test)10 Logger (org.slf4j.Logger)6 Appender (ch.qos.logback.core.Appender)5 SizeBasedTriggeringPolicy (ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy)5 Path (java.nio.file.Path)5 OutputStreamAppender (ch.qos.logback.core.OutputStreamAppender)4 FixedWindowRollingPolicy (ch.qos.logback.core.rolling.FixedWindowRollingPolicy)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