Search in sources :

Example 6 with ThresholdFilter

use of ch.qos.logback.classic.filter.ThresholdFilter in project AJSC by att.

the class loggingConfigurationTest method getThresholdFilterInstanceTest.

@Test
public void getThresholdFilterInstanceTest() {
    System.out.println("Running getThresholdFilterInstanceTest");
    LoggingConfigurationService l = new LoggingConfigurationService();
    l.init();
    ThresholdFilter tf = (ThresholdFilter) l.getThresholdFilterInstance();
    assertEquals("ch.qos.logback.classic.filter.ThresholdFilter", tf.getClass().getName());
}
Also used : ThresholdFilter(ch.qos.logback.classic.filter.ThresholdFilter) Test(org.junit.Test)

Example 7 with ThresholdFilter

use of ch.qos.logback.classic.filter.ThresholdFilter in project dropwizard by dropwizard.

the class ThresholdLevelFilterFactory method build.

/**
 * Creates and starts a {@link Filter} for the given threshold.
 * @param threshold The minimum event level for this filter.
 * @return a new, started {@link Filter}
 */
@Override
public Filter<ILoggingEvent> build(Level threshold) {
    final ThresholdFilter filter = new ThresholdFilter();
    filter.setLevel(threshold.toString());
    filter.start();
    return filter;
}
Also used : ThresholdFilter(ch.qos.logback.classic.filter.ThresholdFilter)

Example 8 with ThresholdFilter

use of ch.qos.logback.classic.filter.ThresholdFilter in project Terasology by MovingBlocks.

the class TelemetryLogstashAppender method addErrorFilter.

private void addErrorFilter() {
    ThresholdFilter filter = new ThresholdFilter();
    filter.setLevel("error");
    filter.start();
    this.addFilter(filter);
}
Also used : ThresholdFilter(ch.qos.logback.classic.filter.ThresholdFilter)

Example 9 with ThresholdFilter

use of ch.qos.logback.classic.filter.ThresholdFilter in project dropwizard by dropwizard.

the class BootstrapLogging method bootstrap.

public static void bootstrap(Level level) {
    LoggingUtil.hijackJDKLogging();
    BOOTSTRAPPING_LOCK.lock();
    try {
        if (bootstrapped) {
            return;
        }
        final Logger root = LoggingUtil.getLoggerContext().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
        root.detachAndStopAllAppenders();
        final DropwizardLayout formatter = new DropwizardLayout(root.getLoggerContext(), TimeZone.getDefault());
        formatter.start();
        final ThresholdFilter filter = new ThresholdFilter();
        filter.setLevel(level.toString());
        filter.start();
        final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
        appender.addFilter(filter);
        appender.setContext(root.getLoggerContext());
        final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder = new LayoutWrappingEncoder<>();
        layoutEncoder.setLayout(formatter);
        appender.setEncoder(layoutEncoder);
        appender.start();
        root.addAppender(appender);
        bootstrapped = true;
    } finally {
        BOOTSTRAPPING_LOCK.unlock();
    }
}
Also used : ConsoleAppender(ch.qos.logback.core.ConsoleAppender) ThresholdFilter(ch.qos.logback.classic.filter.ThresholdFilter) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LayoutWrappingEncoder(ch.qos.logback.core.encoder.LayoutWrappingEncoder)

Example 10 with ThresholdFilter

use of ch.qos.logback.classic.filter.ThresholdFilter in project ANNIS by korpling.

the class AnnisBaseRunner method setupLogging.

// configure logging
public static void setupLogging(boolean console) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    JoranConfigurator jc = new JoranConfigurator();
    jc.setContext(loggerContext);
    loggerContext.reset();
    try {
        jc.doConfigure(System.getProperty("annis.home") + "/conf/logback.xml");
    } catch (JoranException ex) {
        System.out.println(ex.getMessage());
    }
    ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();
    consoleAppender.setContext(loggerContext);
    consoleAppender.setName("CONSOLE");
    consoleAppender.setLayout(new ConsoleLayout());
    ThresholdFilter consoleFilter = new ConsoleFilter();
    consoleFilter.setLevel(console ? "DEBUG" : "WARN");
    consoleFilter.start();
    consoleAppender.addFilter(consoleFilter);
    consoleAppender.setTarget("System.err");
    consoleAppender.start();
    ch.qos.logback.classic.Logger logbackLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    logbackLogger.addAppender(consoleAppender);
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    ;
    SLF4JBridgeHandler.install();
}
Also used : ConsoleAppender(ch.qos.logback.core.ConsoleAppender) ThresholdFilter(ch.qos.logback.classic.filter.ThresholdFilter) JoranException(ch.qos.logback.core.joran.spi.JoranException) JoranConfigurator(ch.qos.logback.classic.joran.JoranConfigurator) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LoggerContext(ch.qos.logback.classic.LoggerContext)

Aggregations

ThresholdFilter (ch.qos.logback.classic.filter.ThresholdFilter)14 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)5 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)5 LoggerContext (ch.qos.logback.classic.LoggerContext)4 Test (org.junit.Test)4 Logger (ch.qos.logback.classic.Logger)3 Appender (ch.qos.logback.core.Appender)3 Level (ch.qos.logback.classic.Level)2 SyslogAppender (ch.qos.logback.classic.net.SyslogAppender)2 FileAppender (ch.qos.logback.core.FileAppender)2 OutputStreamAppender (ch.qos.logback.core.OutputStreamAppender)2 LayoutWrappingEncoder (ch.qos.logback.core.encoder.LayoutWrappingEncoder)2 SentryAppender (io.sentry.logback.SentryAppender)2 Field (java.lang.reflect.Field)2 PmsConfiguration (net.pms.configuration.PmsConfiguration)2 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)1 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)1 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 Filter (ch.qos.logback.core.filter.Filter)1 JoranException (ch.qos.logback.core.joran.spi.JoranException)1