org.apache.log4j.filter
Class AndFilter
java.lang.Object
|
+--org.apache.log4j.spi.ComponentBase
|
+--org.apache.log4j.spi.Filter
|
+--org.apache.log4j.filter.AndFilter
- All Implemented Interfaces:
- Component, OptionHandler
- public class AndFilter
- extends Filter
A filter that 'and's the results of any number of contained filters together.
For the filter to process events, all contained filters must return Filter.ACCEPT.
If the contained filters do not return Filter.ACCEPT, Filter.NEUTRAL is returned.
If acceptOnMatch is set to true, Filter.ACCEPT is returned.
If acceptOnMatch is set to false, Filter.DENY is returned.
Here is an example config that will accept only events that contain BOTH
a DEBUG level AND 'test' in the message:
To accept all events EXCEPT those events that contain a
DEBUG level and 'test' in the message:
change the AndFilter's acceptOnMatch param to false and remove the DenyAllFilter
NOTE: If you are defining a filter that is only relying on logging event content
(no external or filter-managed state), you could opt instead
to use an ExpressionFilter with one of the following expressions:
LEVEL == DEBUG && MSG ~= 'test'
or
! ( LEVEL == DEBUG && MSG ~= 'test' )
- Author:
- Scott Deboy sdeboy@apache.org
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AndFilter
public AndFilter()
activateOptions
public void activateOptions()
- Description copied from class:
Filter
- Usually filters options become active when set. We provide a
default do-nothing implementation for convenience.
- Specified by:
activateOptions
in interface OptionHandler
- Overrides:
activateOptions
in class Filter
addFilter
public void addFilter(Filter filter)
setAcceptOnMatch
public void setAcceptOnMatch(boolean acceptOnMatch)
decide
public int decide(LoggingEvent event)
- If this event does not already contain location information,
evaluate the event against the expression.
If the expression evaluates to true, generate a LocationInfo instance
by creating an exception and set this LocationInfo on the event.
Returns
Filter.NEUTRAL
- Specified by:
decide
in class Filter
- Parameters:
event
- The LoggingEvent to decide upon.
Copyright 2000-2005 Apache Software Foundation.