public class ExpressionRule extends AbstractRule
RuleFactory
.
NOTE: parsing is supported through the use of
StringTokenizer
, which
implies two limitations:
1: all tokens in the expression must be separated by spaces,
including parenthesis
2: operands which contain spaces MUST be wrapped in single quotes.
For example, the expression:
msg == 'some msg'
is a valid expression.
3: To group expressions, use parentheses.
For example, the expression:
level >= INFO || ( msg == 'some msg' || logger == 'test' )
is a valid expression.
See org.apache.log4j.rule.InFixToPostFix for a
description of supported operators.
See org.apache.log4j.spi.LoggingEventFieldResolver for field keywords.Modifier and Type | Method and Description |
---|---|
boolean |
evaluate(org.apache.log4j.spi.LoggingEvent event,
Map matches)
Returns true if this implementation of the rule accepts the LoggingEvent,
or false if not.
|
static Rule |
getRule(String expression)
Get rule.
|
static Rule |
getRule(String expression,
boolean isPostFix)
Get rule.
|
String |
toString() |
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
public static Rule getRule(String expression)
expression
- expression.public static Rule getRule(String expression, boolean isPostFix)
expression
- expression.isPostFix
- If post-fix.public boolean evaluate(org.apache.log4j.spi.LoggingEvent event, Map matches)
What True/False means can be client-specific.
event
- LoggingEvent this instance will evaluatematches
- a Map of event field keys to Sets of matching strings (may be null) which will be
updated during execution of this method to include field and string matches based on the rule
evaluation resultsCopyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0
Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.