本文整理汇总了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;
}
}
}
}
示例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
}