本文整理了Java中org.apache.log4j.Appender.addFilter()
方法的一些代码示例,展示了Appender.addFilter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Appender.addFilter()
方法的具体详情如下:
包路径:org.apache.log4j.Appender
类名称:Appender
方法名:addFilter
[英]Add a filter to the end of the filter list.
[中]将筛选器添加到筛选器列表的末尾。
代码示例来源:origin: log4j/log4j
LogLog.debug("Adding filter of type ["+filter.getClass()
+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);
代码示例来源:origin: log4j/log4j
LogLog.debug("Adding filter of type ["+filter.getClass()
+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);
代码示例来源:origin: apache/ignite
/**
* Creates console appender with some reasonable default logging settings.
*
* @param maxLevel Max logging level.
* @return New console appender.
*/
private Appender createConsoleAppender(Level maxLevel) {
String fmt = "[%d{ISO8601}][%-5p][%t][%c{1}] %m%n";
// Configure output that should go to System.out
Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.TRACE);
lvlFilter.setLevelMax(maxLevel);
app.addFilter(lvlFilter);
return app;
}
代码示例来源:origin: apache/ignite
/**
* Creates console appender with some reasonable default logging settings.
*
* @param maxLevel Max logging level.
* @return New console appender.
*/
private Appender createConsoleAppender(Level maxLevel) {
String fmt = "[%d{ISO8601}][%-5p][%t][%c{1}] %m%n";
// Configure output that should go to System.out
Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.TRACE);
lvlFilter.setLevelMax(maxLevel);
app.addFilter(lvlFilter);
return app;
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
Used internally to parse a filter element.
*/
protected
void parseFilters(Element element, Appender appender) {
String clazz = subst(element.getAttribute(CLASS_ATTR));
Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz,
Filter.class, null);
if(filter != null) {
PropertySetter propSetter = new PropertySetter(filter);
NodeList children = element.getChildNodes();
final int length = children.getLength();
for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
Element currentElement = (Element) currentNode;
String tagName = currentElement.getTagName();
if(tagName.equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
}
}
}
propSetter.activate();
LogLog.debug("Adding filter of type ["+filter.getClass()
+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);
}
}
代码示例来源:origin: apache/log4j
LogLog.debug("Adding filter of type ["+filter.getClass()
+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);
代码示例来源:origin: apache/log4j
LogLog.debug("Adding filter of type ["+filter.getClass()
+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
public void addFilter(Filter arg0)
{
m_other.addFilter(arg0);
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
@Override
public void addFilter(Filter arg0) {
delegate().addFilter(arg0);
}
代码示例来源:origin: org.terracotta/terracotta-l1
@Override
public void addFilter(Filter arg0) {
delegate().addFilter(arg0);
}
代码示例来源:origin: org.terracotta/terracotta-ee
@Override
public void addFilter(Filter arg0) {
delegate().addFilter(arg0);
}
代码示例来源:origin: BiglySoftware/BiglyBT
/** Creates a new instance of Main */
/*public UI() {
}*/
public static void initRootLogger() {
if (Logger.getRootLogger().getAppender("ConsoleAppender") == null) {
Appender app;
app = new ConsoleAppender(
new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
app.setName("ConsoleAppender");
app.addFilter(new DenyAllFilter()); //'log off' by default
Logger.getRootLogger().addAppender(app);
}
}
代码示例来源:origin: com.jdroidtools/jdroid-java-webapp-core
/**
* @see org.apache.log4j.spi.AppenderAttachable#addAppender(org.apache.log4j.Appender)
*/
@Override
public void addAppender(final Appender newAppender) {
synchronized (appenders) {
// We don't want the downstream appender to receive logging events via the normal Log4J
// mechanism; we only want it to receive the logging events that WE send to it. So we add
// the DenyAllFilter so that Log4J does not deliver logging events to it.
newAppender.addFilter(new DenyAllFilter());
appenders.addAppender(newAppender);
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Simple constructor to allow other components to use the console commands such as "set"
* @param core
* @param _out
*/
public ConsoleInput(Core core, PrintStream _out )
{
super( "" );
this.out = _out;
this.core = core;
this.userProfile = UserProfile.DEFAULT_USER_PROFILE;
this.controlling = false;
this.br = new CommandReader( new InputStreamReader( new ByteArrayInputStream(new byte[0])));
if (Logger.getRootLogger().getAppender("ConsoleAppender")==null) {
Appender app;
app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
app.setName("ConsoleAppender");
app.addFilter( new DenyAllFilter() ); //'log off' by default
Logger.getRootLogger().addAppender(app);
}
initialise();
}
代码示例来源:origin: org.gridgain/gridgain-log4j
/**
* Creates console appender with some reasonable default logging settings.
*
* @param maxLevel Max logging level.
* @return New console appender.
*/
private Appender createConsoleAppender(Level maxLevel) {
String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
// Configure output that should go to System.out
Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.TRACE);
lvlFilter.setLevelMax(maxLevel);
app.addFilter(lvlFilter);
return app;
}
代码示例来源:origin: org.apache.ignite/ignite-log4j
/**
* Creates console appender with some reasonable default logging settings.
*
* @param maxLevel Max logging level.
* @return New console appender.
*/
private Appender createConsoleAppender(Level maxLevel) {
String fmt = "[%d{ISO8601}][%-5p][%t][%c{1}] %m%n";
// Configure output that should go to System.out
Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.TRACE);
lvlFilter.setLevelMax(maxLevel);
app.addFilter(lvlFilter);
return app;
}
代码示例来源:origin: org.kuali.kfs/kfs-core
protected void initializeLogging(JobExecutionContext jobExecutionContext) {
try {
Calendar startTimeCalendar = dateTimeService.getCurrentCalendar();
StringBuffer nestedDiagnosticContext = new StringBuffer(StringUtils.substringAfter(BatchSpringContext.getJobDescriptor(jobExecutionContext.getJobDetail().getName()).getNamespaceCode(), "-").toLowerCase()).append(File.separator).append(jobExecutionContext.getJobDetail().getName()).append("-").append(dateTimeService.toDateTimeStringForFilename(dateTimeService.getCurrentDate()));
((Job) jobExecutionContext.getJobInstance()).setNdcAppender(new FileAppender(Logger.getRootLogger().getAppender("LogFile").getLayout(), getLogFileName(nestedDiagnosticContext.toString())));
((Job) jobExecutionContext.getJobInstance()).getNdcAppender().addFilter(new NDCFilter(nestedDiagnosticContext.toString()));
Logger.getRootLogger().addAppender(((Job) jobExecutionContext.getJobInstance()).getNdcAppender());
NDC.push(nestedDiagnosticContext.toString());
}
catch (IOException e) {
LOG.warn("Could not initialize special custom logging for job: " + jobExecutionContext.getJobDetail().getName(), e);
}
}
代码示例来源:origin: com.jdroidtools/jdroid-java-webapp-core
private synchronized void consolidateEventsAndForward(String loggerName) {
// TODO Add support to multiple appenders
Appender downstreamAppender = (Appender)appenders.getAllAppenders().nextElement();
List<LoggingEvent> existingEvents = cachedEvents.remove(loggerName);
if (CollectionUtils.isNotEmpty(existingEvents)) {
LoggingEvent eventToSendDownstream;
if (existingEvents.size() == 1) {
eventToSendDownstream = existingEvents.get(0);
} else {
eventToSendDownstream = consolidatedEvent(existingEvents, downstreamAppender.getLayout());
}
// To deliver the consolidated event to the downstream appender, we temporarily
// remove and then reinstate the DenyAllFilter
downstreamAppender.clearFilters();
downstreamAppender.doAppend(eventToSendDownstream);
downstreamAppender.addFilter(new DenyAllFilter());
}
}
代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j
LogLog.debug("Adding filter of type ["+filter.getClass()
+"] to appender named ["+appender.getName()+"].");
appender.addFilter(filter);
代码示例来源:origin: org.eclipse.xtext/org.eclipse.xtext.junit4
private static void removeFilter(final Appender appender, final Filter filter) {
Filter _filter = appender.getFilter();
boolean _equals = Objects.equal(_filter, filter);
if (_equals) {
appender.clearFilters();
Filter _next = filter.getNext();
appender.addFilter(_next);
} else {
for (Filter current = appender.getFilter(); (!Objects.equal(current, null)); current = current.getNext()) {
Filter _next_1 = current.getNext();
boolean _equals_1 = Objects.equal(_next_1, filter);
if (_equals_1) {
Filter _next_2 = filter.getNext();
current.setNext(_next_2);
return;
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!