Search in sources :

Example 36 with ConsoleAppender

use of ch.qos.logback.core.ConsoleAppender in project midpoint by Evolveum.

the class Log method setupAppender.

private ConsoleAppender setupAppender(String name, String target, LoggerContext ctx, Encoder enc) {
    ConsoleAppender appender = new ConsoleAppender();
    appender.setName(name);
    appender.setTarget(target);
    appender.setContext(ctx);
    appender.setEncoder(enc);
    appender.start();
    return appender;
}
Also used : ConsoleAppender(ch.qos.logback.core.ConsoleAppender)

Example 37 with ConsoleAppender

use of ch.qos.logback.core.ConsoleAppender in project chunkstories by Hugobros3.

the class LogbackSetupHelper method setupLoggingForTesting.

public static void setupLoggingForTesting() {
    ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    String pattern = "%date %level [%logger] %msg%n";
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    PatternLayoutEncoder ple2 = new PatternLayoutEncoder();
    ple2.setPattern(pattern);
    ple2.setContext(lc);
    ple2.start();
    ConsoleAppender<ILoggingEvent> logConsoleAppender = new ConsoleAppender<>();
    logConsoleAppender.setContext(lc);
    logConsoleAppender.setName("console");
    logConsoleAppender.setEncoder(ple2);
    logConsoleAppender.start();
    rootLogger.addAppender(logConsoleAppender);
    rootLogger.setLevel(Level.ALL);
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) ConsoleAppender(ch.qos.logback.core.ConsoleAppender) Logger(org.slf4j.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext)

Example 38 with ConsoleAppender

use of ch.qos.logback.core.ConsoleAppender in project bgpcep by opendaylight.

the class LoggerUtil method createConsoleAppender.

private static ConsoleAppender<ILoggingEvent> createConsoleAppender(final LoggerContext loggerContext) {
    final PatternLayoutEncoder ple = new PatternLayoutEncoder();
    ple.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{10} - %msg%n");
    ple.setContext(loggerContext);
    ple.start();
    final ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();
    consoleAppender.setContext(loggerContext);
    consoleAppender.setEncoder(ple);
    consoleAppender.setName("STDOUT");
    consoleAppender.start();
    return consoleAppender;
}
Also used : PatternLayoutEncoder(ch.qos.logback.classic.encoder.PatternLayoutEncoder) ConsoleAppender(ch.qos.logback.core.ConsoleAppender) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Aggregations

ConsoleAppender (ch.qos.logback.core.ConsoleAppender)38 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)31 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)21 LoggerContext (ch.qos.logback.classic.LoggerContext)19 Logger (ch.qos.logback.classic.Logger)16 Appender (ch.qos.logback.core.Appender)10 FileAppender (ch.qos.logback.core.FileAppender)9 Test (org.junit.Test)8 ThresholdFilter (ch.qos.logback.classic.filter.ThresholdFilter)5 OutputStreamAppender (ch.qos.logback.core.OutputStreamAppender)5 LayoutWrappingEncoder (ch.qos.logback.core.encoder.LayoutWrappingEncoder)5 SyslogAppender (ch.qos.logback.classic.net.SyslogAppender)4 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 AsyncAppender (ch.qos.logback.classic.AsyncAppender)2 JoranException (ch.qos.logback.core.joran.spi.JoranException)2 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)2 MetricRegistry (com.codahale.metrics.MetricRegistry)2 PmsConfiguration (net.pms.configuration.PmsConfiguration)2