當前位置: 首頁>>代碼示例>>Java>>正文


Java Appender.addFilter方法代碼示例

本文整理匯總了Java中ch.qos.logback.core.Appender.addFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java Appender.addFilter方法的具體用法?Java Appender.addFilter怎麽用?Java Appender.addFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.core.Appender的用法示例。


在下文中一共展示了Appender.addFilter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setMetricsMarkerLogbackFilter

import ch.qos.logback.core.Appender; //導入方法依賴的package包/類
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();
            }
        }
    }
}
 
開發者ID:torgcrm,項目名稱:TorgCRM-Server,代碼行數:25,代碼來源:LoggingConfiguration.java

示例2: setMetricsMarkerLogbackFilter

import ch.qos.logback.core.Appender; //導入方法依賴的package包/類
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();
            }
        }
    }
}
 
開發者ID:asanzdiego,項目名稱:codemotion-2017-taller-de-jhipster,代碼行數:25,代碼來源:LoggingConfiguration.java

示例3: build

import ch.qos.logback.core.Appender; //導入方法依賴的package包/類
@Override
public Appender<E> build(final LoggerContext context,
                         final String applicationName,
                         final LayoutFactory<E> layoutFactory,
                         final LevelFilterFactory<E> levelFilterFactory,
                         final AsyncAppenderFactory<E> asyncAppenderFactory) {
    final Appender<E> appender = new FifoLogbackAppender<>();

    appender.setContext(context);

    appender.addFilter(levelFilterFactory.build(threshold));
    getFilterFactories().forEach(f -> appender.addFilter(f.build()));
    appender.start();
    appender.setName(APPENDER_NAME);

    return appender;
}
 
開發者ID:gchq,項目名稱:stroom-query,代碼行數:18,代碼來源:FifoLogbackAppenderFactory.java

示例4: addSampleLogger

import ch.qos.logback.core.Appender; //導入方法依賴的package包/類
/**
 * Allow only selected logger to print DEBUG events to STDOUT and FILE.
 * Other loggers are allowed to print ERRORS only.
 */
private static void addSampleLogger(final String loggerName) {
    if (CUSTOM_FILTER == null) {
        CUSTOM_FILTER = new CustomFilter();
        final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

        Appender ca = loggerContext.getLogger("ROOT").getAppender("STDOUT");
        ca.clearAllFilters();
        ca.addFilter(CUSTOM_FILTER);
    }
    CUSTOM_FILTER.addVisibleLogger(loggerName);
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:16,代碼來源:BasicSample.java

示例5: build

import ch.qos.logback.core.Appender; //導入方法依賴的package包/類
@Override
public Appender<E> build(final LoggerContext context,
                      final String applicationName,
                      final LayoutFactory<E> layoutFactory,
                      final LevelFilterFactory<E> levelFilterFactory,
                      final AsyncAppenderFactory<E> asyncAppenderFactory) {

    final Properties producerConfigProperties = producerConfig.stream()
            .map(s -> s.split("="))
            .filter(values -> values.length == 2)
            .reduce(new Properties(), (props, values) -> {
                props.setProperty(values[0], values[1]);
                return props;
            }, (p1, p2) -> {
                Properties merged = new Properties();
                merged.putAll(p1);
                merged.putAll(p2);
                return merged;
            });

    final Appender<E> appender = new KafkaLogbackAppender<>(producerConfigProperties, topic);

    appender.setContext(context);

    appender.addFilter(levelFilterFactory.build(threshold));
    getFilterFactories().forEach(f -> appender.addFilter(f.build()));
    appender.start();
    appender.setName(APPENDER_NAME);

    return appender;
    //return wrapAsync(appender, asyncAppenderFactory);
}
 
開發者ID:gchq,項目名稱:stroom-query,代碼行數:33,代碼來源:KafkaLogbackAppenderFactory.java

示例6: setConsoleLogLevel

import ch.qos.logback.core.Appender; //導入方法依賴的package包/類
private static void setConsoleLogLevel() {
  String loglevelAsString = System.getProperty("tmm.consoleloglevel", "");
  Level level;

  switch (loglevelAsString) {
    case "ERROR":
      level = Level.TRACE;
      break;

    case "WARN":
      level = Level.WARN;
      break;

    case "INFO":
      level = Level.INFO;
      break;

    case "DEBUG":
      level = Level.DEBUG;
      break;

    case "TRACE":
      level = Level.TRACE;
      break;

    default:
      return;
  }

  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

  // get the console appener
  Appender consoleAppender = lc.getLogger("ROOT").getAppender("CONSOLE");
  if (consoleAppender instanceof ConsoleAppender) {
    // and set a filter to drop messages beneath the given level
    ThresholdLoggerFilter filter = new ThresholdLoggerFilter(level);
    filter.start();
    consoleAppender.addFilter(filter);
  }
}
 
開發者ID:tinyMediaManager,項目名稱:tinyMediaManager,代碼行數:41,代碼來源:TinyMediaManager.java


注:本文中的ch.qos.logback.core.Appender.addFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。