当前位置: 首页>>代码示例>>Java>>正文


Java Appender.clearFilters方法代码示例

本文整理汇总了Java中org.apache.log4j.Appender.clearFilters方法的典型用法代码示例。如果您正苦于以下问题:Java Appender.clearFilters方法的具体用法?Java Appender.clearFilters怎么用?Java Appender.clearFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.Appender的用法示例。


在下文中一共展示了Appender.clearFilters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeFilter

import org.apache.log4j.Appender; //导入方法依赖的package包/类
private static void removeFilter(final Appender appender, final Filter filter) {
  Filter _filter = appender.getFilter();
  boolean _equals = Objects.equal(_filter, filter);
  if (_equals) {
    appender.clearFilters();
    appender.addFilter(filter.getNext());
  } else {
    for (Filter current = appender.getFilter(); (current != null); current = current.getNext()) {
      Filter _next = current.getNext();
      boolean _equals_1 = Objects.equal(_next, filter);
      if (_equals_1) {
        current.setNext(filter.getNext());
        return;
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:LoggingTester.java

示例2: revert

import org.apache.log4j.Appender; //导入方法依赖的package包/类
@Override
@SuppressWarnings( "unchecked")
public void revert() {

    /*
     * This code is run on remote agent's side
     */

    /*
     * The outer code will call this method when the "needs applying" method return true.
     * 
     * Currently we could come here because of 2 reasons:
     *  - the DB appenders must be reconfigured
     *  - the user loggers must be reconfigured
     */

    if (appenderLogger != null && needsToConfigureDbAppender) {
        // there is a DB appender and it is out-of-date

        //remove the filter which will deny logging of system events
        Logger rootLogger = Logger.getRootLogger();
        Enumeration<Appender> appenders = rootLogger.getAllAppenders();
        while (appenders.hasMoreElements()) {
            Appender appender = appenders.nextElement();

            //remove the filter
            //FIXME:This is very risky, as someone may have added other filters
            //the current implementation of the filter chain in log4j will not allow
            //us to easily remove a single filter
            appender.clearFilters();
        }

        Category log;
        if ("root".equals(appenderLogger)) {
            log = Logger.getRootLogger();
        } else {
            log = Logger.getLogger(appenderLogger);
        }

        Appender dbAppender = PassiveDbAppender.getCurrentInstance(ThreadsPerCaller.getCaller());
        if (dbAppender != null) {
            //close the appender
            dbAppender.close();

            //remove it
            log.removeAppender(dbAppender);
        }
    }

    // in case we must reconfigure the custom loggers, here we should remove them from log4j, 
    // but log4j does not provide a way to do it - so we do nothing here 
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:53,代码来源:RemoteLoggingConfigurator.java


注:本文中的org.apache.log4j.Appender.clearFilters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。