org.apache.log4j.rule
Class ExpressionRule
java.lang.Object
|
+--org.apache.log4j.rule.AbstractRule
|
+--org.apache.log4j.rule.ExpressionRule
- All Implemented Interfaces:
- Rule, 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
getRule
public static Rule getRule(String expression)
getRule
public static Rule getRule(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.
- Following copied from interface:
org.apache.log4j.rule.Rule
- Parameters:
e
- LoggingEvent this instance will evaluate- Returns:
- true if this Rule instance accepts the event, otherwise false.
toString
public String toString()
- Overrides:
toString
in class Object
Copyright © 2000-2006 Apache Software Foundation.
Licensed under the Apache License, Version 2.0.