Search in sources :

Example 81 with Appender

use of ch.qos.logback.core.Appender in project jhipster-sample-app-dto by jhipster.

the class LoggingConfiguration method setMetricsMarkerLogbackFilter.

// Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();
    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
Also used : LogstashTcpSocketAppender(net.logstash.logback.appender.LogstashTcpSocketAppender) Appender(ch.qos.logback.core.Appender) AsyncAppender(ch.qos.logback.classic.AsyncAppender) OnMarkerEvaluator(ch.qos.logback.classic.boolex.OnMarkerEvaluator) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EvaluatorFilter(ch.qos.logback.core.filter.EvaluatorFilter)

Example 82 with Appender

use of ch.qos.logback.core.Appender in project jhipster-sample-app-websocket by jhipster.

the class LoggingConfiguration method setMetricsMarkerLogbackFilter.

// Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();
    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
Also used : LogstashTcpSocketAppender(net.logstash.logback.appender.LogstashTcpSocketAppender) Appender(ch.qos.logback.core.Appender) AsyncAppender(ch.qos.logback.classic.AsyncAppender) OnMarkerEvaluator(ch.qos.logback.classic.boolex.OnMarkerEvaluator) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EvaluatorFilter(ch.qos.logback.core.filter.EvaluatorFilter)

Example 83 with Appender

use of ch.qos.logback.core.Appender in project jhipster-sample-app-cassandra by jhipster.

the class LoggingConfiguration method setMetricsMarkerLogbackFilter.

// Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();
    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
Also used : LogstashTcpSocketAppender(net.logstash.logback.appender.LogstashTcpSocketAppender) Appender(ch.qos.logback.core.Appender) AsyncAppender(ch.qos.logback.classic.AsyncAppender) OnMarkerEvaluator(ch.qos.logback.classic.boolex.OnMarkerEvaluator) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EvaluatorFilter(ch.qos.logback.core.filter.EvaluatorFilter)

Example 84 with Appender

use of ch.qos.logback.core.Appender in project hello-world by haoziapple.

the class LoggingConfiguration method setMetricsMarkerLogbackFilter.

// Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();
    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
Also used : LogstashTcpSocketAppender(net.logstash.logback.appender.LogstashTcpSocketAppender) Appender(ch.qos.logback.core.Appender) AsyncAppender(ch.qos.logback.classic.AsyncAppender) OnMarkerEvaluator(ch.qos.logback.classic.boolex.OnMarkerEvaluator) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EvaluatorFilter(ch.qos.logback.core.filter.EvaluatorFilter)

Example 85 with Appender

use of ch.qos.logback.core.Appender in project atlasdb by palantir.

the class ProfilingKeyValueServiceTest method dropTableTraceLogPresentOnTraceLevel.

@Test
public void dropTableTraceLogPresentOnTraceLevel() {
    Appender mockAppender = setLogLevelAndGetAppender(Level.TRACE);
    kvs.dropTable(TABLE_REF);
    verify(mockAppender).doAppend(traceLogMatcher.get());
}
Also used : Appender(ch.qos.logback.core.Appender) Test(org.junit.Test)

Aggregations

Appender (ch.qos.logback.core.Appender)118 Test (org.junit.Test)62 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)51 Logger (ch.qos.logback.classic.Logger)32 LoggerContext (ch.qos.logback.classic.LoggerContext)32 FileAppender (ch.qos.logback.core.FileAppender)27 Logger (org.slf4j.Logger)25 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)21 ArgumentMatcher (org.mockito.ArgumentMatcher)19 AsyncAppender (ch.qos.logback.classic.AsyncAppender)18 File (java.io.File)14 OnMarkerEvaluator (ch.qos.logback.classic.boolex.OnMarkerEvaluator)13 EvaluatorFilter (ch.qos.logback.core.filter.EvaluatorFilter)13 LogstashTcpSocketAppender (net.logstash.logback.appender.LogstashTcpSocketAppender)13 ArrayList (java.util.ArrayList)11 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)11 OutputStreamAppender (ch.qos.logback.core.OutputStreamAppender)10 RollingFileAppender (ch.qos.logback.core.rolling.RollingFileAppender)9 DBAppender (ch.qos.logback.classic.db.DBAppender)8 Test (org.junit.jupiter.api.Test)7