Package org.apache.log4j.filter
Class ExpressionFilter
java.lang.Object
org.apache.log4j.spi.Filter
org.apache.log4j.filter.ExpressionFilter
- All Implemented Interfaces:
org.apache.log4j.spi.OptionHandler
public class ExpressionFilter
extends org.apache.log4j.spi.Filter
A filter supporting complex expressions - supports both infix and postfix
expressions (infix expressions must first be converted to postfix prior
to processing).
See org.apache.log4j.chainsaw.LoggingEventFieldResolver.java
for the correct names for logging event fields
used when building expressions.
See org.apache.log4j.chainsaw.rule
package
for a list of available
rules which can be applied using the expression syntax.
See org.apache.log4j.chainsaw.RuleFactory
for the symbols
used to activate the corresponding rules.
LoggingEvent
and AcceptOnMatch is true,
the decide(org.apache.log4j.spi.LoggingEvent)
method returns Filter.ACCEPT
.
If there is a match between the value of the
Expression option and the LoggingEvent
and AcceptOnMatch is false,
Filter.DENY
is returned.
If there is no match, Filter.NEUTRAL
is returned.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
accept on match.(package private) boolean
Convert in-fix to post-fix.(package private) String
Expression.(package private) Rule
Evaluated rule.Fields inherited from class org.apache.log4j.spi.Filter
ACCEPT, DENY, NEUTRAL, next
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
decide
(org.apache.log4j.spi.LoggingEvent event) Determines if event matches the filter.boolean
Gets whether filter accepts matching or non-matching events.boolean
Get in-fix to post-fix conversion setting.Get expression.void
setAcceptOnMatch
(boolean newValue) Set whether filter should accept events if they match the expression.void
setConvertInFixToPostFix
(boolean newValue) Set convert in-fix to post-fix.void
setExpression
(String exp) Set exp.Methods inherited from class org.apache.log4j.spi.Filter
getNext, setNext
-
Field Details
-
Constructor Details
-
ExpressionFilter
public ExpressionFilter()
-
-
Method Details
-
activateOptions
public void activateOptions()- Specified by:
activateOptions
in interfaceorg.apache.log4j.spi.OptionHandler
- Overrides:
activateOptions
in classorg.apache.log4j.spi.Filter
-
setExpression
Set exp.- Parameters:
exp
- exp.
-
getExpression
Get expression.- Returns:
- expression.
-
setConvertInFixToPostFix
public void setConvertInFixToPostFix(boolean newValue) Set convert in-fix to post-fix.- Parameters:
newValue
- new value.
-
getConvertInFixToPostFix
public boolean getConvertInFixToPostFix()Get in-fix to post-fix conversion setting.- Returns:
- true if in-fix expressions are converted to post-fix.
-
setAcceptOnMatch
public void setAcceptOnMatch(boolean newValue) Set whether filter should accept events if they match the expression.- Parameters:
newValue
- if true, accept on match.
-
getAcceptOnMatch
public boolean getAcceptOnMatch()Gets whether filter accepts matching or non-matching events.- Returns:
- if true, accept matching events.
-
decide
public int decide(org.apache.log4j.spi.LoggingEvent event) Determines if event matches the filter.- Specified by:
decide
in classorg.apache.log4j.spi.Filter
- Parameters:
event
- logging event;- Returns:
Filter.NEUTRAL
is there is no string match.
-