Log4j 1.3alpha-7

org.apache.log4j.filter
Class ExpressionFilter

java.lang.Object
  extended byorg.apache.log4j.spi.ComponentBase
      extended byorg.apache.log4j.spi.Filter
          extended byorg.apache.log4j.filter.ExpressionFilter
All Implemented Interfaces:
Component, OptionHandler

public class ExpressionFilter
extends 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 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. NOTE: Grouping using parentheses is supported - all tokens must be separated by spaces, and operands which contain spaces are not yet supported. Example: In order to build a filter that displays all messages with infomsg-45 or infomsg-44 in the message, as well as all messages with a level of WARN or higher, build an expression using the LikeRule (supports ORO-based regular expressions) and the InequalityRule. ( MSG LIKE infomsg-4[4,5] ) && ( LEVEL >= WARN ) Three options are required: Expression - the expression to match ConvertInFixToPostFix - convert from infix to posfix (default true) AcceptOnMatch - true or false (default true) Meaning of AcceptToMatch: If there is a match between the value of the Expression option and the 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.

Author:
Scott Deboy sdeboy@apache.org

Field Summary
 
Fields inherited from class org.apache.log4j.spi.Filter
ACCEPT, DENY, NEUTRAL, next
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
ExpressionFilter()
           
 
Method Summary
 void activateOptions()
          Usually filters options become active when set.
 int decide(LoggingEvent event)
          Returns Filter.NEUTRAL is there is no string match.
 boolean getAcceptOnMatch()
           
 boolean getConvertInFixToPostFix()
           
 String getExpression()
           
 void setAcceptOnMatch(boolean acceptOnMatch)
           
 void setConvertInFixToPostFix(boolean convertInFixToPostFix)
           
 void setExpression(String expression)
           
 
Methods inherited from class org.apache.log4j.spi.Filter
getNext, setNext
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionFilter

public ExpressionFilter()
Method Detail

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

setExpression

public void setExpression(String expression)

getExpression

public String getExpression()

setConvertInFixToPostFix

public void setConvertInFixToPostFix(boolean convertInFixToPostFix)

getConvertInFixToPostFix

public boolean getConvertInFixToPostFix()

setAcceptOnMatch

public void setAcceptOnMatch(boolean acceptOnMatch)

getAcceptOnMatch

public boolean getAcceptOnMatch()

decide

public int decide(LoggingEvent event)
Returns Filter.NEUTRAL is there is no string match.

Specified by:
decide in class Filter
Parameters:
event - The LoggingEvent to decide upon.

Log4j 1.3alpha-7

Copyright 2000-2005 Apache Software Foundation.