ch.qos.logback.core.Appender.addFilter()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中ch.qos.logback.core.Appender.addFilter()方法的一些代码示例,展示了Appender.addFilter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Appender.addFilter()方法的具体详情如下:
包路径:ch.qos.logback.core.Appender
类名称:Appender
方法名:addFilter

Appender.addFilter介绍

暂无

代码示例

代码示例来源:origin: ethereum/ethereumj

/**
 * 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);
}

代码示例来源:origin: kairosdb/kairosdb

if (stdout != null)
  stdout.addFilter(new Filter<ILoggingEvent>()

代码示例来源:origin: caskdata/cdap

@Override
public void addFilter(Filter<E> newFilter) {
 delegate.addFilter(newFilter);
}

代码示例来源:origin: co.cask.cdap/cdap-watchdog

@Override
public void addFilter(Filter<E> newFilter) {
 delegate.addFilter(newFilter);
}

代码示例来源:origin: com.opentable.components/otj-logging

private void doAttach(Appender<ILoggingEvent> appender) {
  if (appender != null) {
    appender.addFilter(filter);
    LoggerFactory.getLogger(AttachLogFilter.class).info("Attached log filter {} to {} '{}'", filter, appender, appenderName);
  } else {
    throw new IllegalStateException("Could not attach log filter to appender " + appenderName);
  }
}

代码示例来源:origin: theotherp/nzbhydra2

@PostConstruct
public void updateMarkersFilter() {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  for (Logger logger : context.getLoggerList()) {
    Iterator<Appender<ILoggingEvent>> appenderIterator = logger.iteratorForAppenders();
    appenderIterator.forEachRemaining(x -> x.addFilter(this));
  }
}

代码示例来源:origin: theotherp/nzbhydra2

@PostConstruct
public void updateMarkersFilter() {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  for (Logger logger : context.getLoggerList()) {
    Iterator<Appender<ILoggingEvent>> appenderIterator = logger.iteratorForAppenders();
    appenderIterator.forEachRemaining(x -> x.addFilter(this));
  }
}

代码示例来源:origin: org.xwiki.commons/xwiki-commons-logging-logback

@Override
public void initialize() throws InitializationException
{
  // Register appender
  ch.qos.logback.classic.Logger rootLogger = getRootLogger();
  if (rootLogger != null) {
    Iterator<Appender<ILoggingEvent>> iterator = rootLogger.iteratorForAppenders();
    while (iterator.hasNext()) {
      Appender<ILoggingEvent> appender = iterator.next();
      if (!(appender instanceof LogbackEventGenerator)) {
        appender.addFilter(this.forbiddenThreads);
      }
    }
  } else {
    this.logger.warn("Could not find any Logback root logger."
      + " All logging module advanced features will be disabled.");
  }
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

consoleAppender.addFilter(filter);

代码示例来源:origin: apache/jackrabbit-oak

public void finished() {
    if (thFilter==null) {
      // then we did not add it
      return;
    }
    List<Filter<ILoggingEvent>> filterList = appender.getCopyOfAttachedFiltersList();
    appender.clearAllFilters();
    for (Iterator<Filter<ILoggingEvent>> it = filterList.iterator(); it.hasNext();) {
      Filter<ILoggingEvent> filter = it.next();
      if (filter!=thFilter) {
        appender.addFilter(filter);
      }
    }
  }
}

代码示例来源:origin: apache/jackrabbit-oak

public void starting() {
  thFilter = new ThresholdFilter();
  thFilter.setLevel(level);
  thFilter.start();
  appender.addFilter(thFilter);
}

代码示例来源:origin: dCache/dcache

@Override
public void start()
{
  LoggerContext context = (LoggerContext) getContext();
  for (Logger logger: context.getLoggerList()) {
    RootFilterThresholds.setRoot(LoggerName.getInstance(logger.getName()), !logger.isAdditive());
  }
  for (Appender<ILoggingEvent> appender: getAppenders(context)) {
    String appenderName = appender.getName();
    RootFilterThresholds.addAppender(appenderName);
    for (Threshold threshold: _thresholds) {
      if (threshold.isApplicableToAppender(appender)) {
        RootFilterThresholds.setThreshold(
            threshold.getLogger(),
            appenderName,
            threshold.getLevel());
      }
    }
    CellThresholdFilterCompanion filter =
      new CellThresholdFilterCompanion(appenderName);
    filter.start();
    appender.addFilter(filter);
  }
  super.start();
}

代码示例来源:origin: org.apache.marmotta/marmotta-core

filter.setContext(loggerContext);
filter.start();
appender.addFilter(filter);

代码示例来源:origin: apache/marmotta

filter.setContext(loggerContext);
filter.start();
appender.addFilter(filter);

相关文章