org.apache.log4j.rule
Class ExpressionRule
java.lang.Object
|
+--org.apache.log4j.rule.AbstractRule
|
+--org.apache.log4j.rule.ExpressionRule
- All Implemented Interfaces:
- Rule, java.io.Serializable
- public class ExpressionRule
- extends AbstractRule
A Rule class supporting both infix and postfix expressions, accepting any rule which
is supported by the 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 parenthese
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.
- Author:
- Scott Deboy
- See Also:
- Serialized Form
Method Summary |
boolean |
evaluate(LoggingEvent event)
Returns true if this implementation of the rule accepts the LoggingEvent, or false if not.
|
static Rule |
getRule(java.lang.String expression)
|
static Rule |
getRule(java.lang.String expression,
boolean isPostFix)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
getRule
public static Rule getRule(java.lang.String expression)
getRule
public static Rule getRule(java.lang.String expression,
boolean isPostFix)
evaluate
public boolean evaluate(LoggingEvent event)
- Description copied from interface:
Rule
- Returns true if this implementation of the rule accepts the LoggingEvent, or false if not.
What True/False means can be client-specific.
- Parameters:
event
- LoggingEvent this instance will evaluate
- Returns:
- true if this Rule instance accepts the event, otherwise false.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
Copyright 2000-2003 Apache Software Foundation.