Apache log4cxx  Version 0.10.0
ExpressionFilter Class Reference

A filter supporting complex expressions - supports both infix and postfix expressions (infix expressions must first be converted to postfix prior to processing). More...

Inheritance diagram for ExpressionFilter:
Filter OptionHandler ObjectImpl Object Object

Public Member Functions

 ExpressionFilter ()
 
void activateOptions (log4cxx::helpers::Pool &p)
 Activate the options that were previously set with calls to option setters. More...
 
void setExpression (const LogString &expression)
 
LogString getExpression () const
 
void setConvertInFixToPostFix (bool convertInFixToPostFix)
 
bool getConvertInFixToPostFix () const
 
void setAcceptOnMatch (bool acceptOnMatch)
 
bool getAcceptOnMatch () const
 
FilterDecision decide (const spi::LoggingEventPtr &event) const
 Returns log4cxx::spi::Filter#NEUTRAL is there is no string match. More...
 
- Public Member Functions inherited from Filter
 Filter ()
 
void addRef () const
 
void releaseRef () const
 
log4cxx::spi::FilterPtr getNext () const
 
void setNext (const log4cxx::spi::FilterPtr &newNext)
 
void activateOptions (log4cxx::helpers::Pool &p)
 Usually filters options become active when set. More...
 
void setOption (const LogString &option, const LogString &value)
 Set option to value. More...
 
- Public Member Functions inherited from OptionHandler
virtual ~OptionHandler ()
 
- Public Member Functions inherited from Object
virtual const helpers::ClassgetClass () const
 
virtual ~Object ()
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 
- Public Member Functions inherited from ObjectImpl
 ObjectImpl ()
 
virtual ~ObjectImpl ()
 

Additional Inherited Members

- Public Types inherited from Filter
enum  FilterDecision { DENY = -1, NEUTRAL = 0, ACCEPT = 1 }
 
- Static Public Member Functions inherited from Object
static const helpers::ClassgetStaticClass ()
 
static const log4cxx::helpers::ClassRegistrationregisterClass ()
 
- Protected Attributes inherited from ObjectImpl
unsigned int volatile ref
 

Detailed Description

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.

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 log4cxx::spi::LoggingEvent and AcceptOnMatch is true, the decide method returns log4cxx::spi::Filter#ACCEPT.

If there is a match between the value of the Expression option and the log4cxx::spi::LoggingEvent and AcceptOnMatch is false, log4cxx::spi::Filter#DENY is returned.

If there is no match, log4cxx::spi::Filter#NEUTRAL is returned.

Constructor & Destructor Documentation

Member Function Documentation

void activateOptions ( log4cxx::helpers::Pool p)
virtual

Activate the options that were previously set with calls to option setters.

This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.

For example, the FileAppender has the File and Append options both of which are ambigous until the other is also set.

Implements OptionHandler.

FilterDecision decide ( const spi::LoggingEventPtr event) const
virtual

Returns log4cxx::spi::Filter#NEUTRAL is there is no string match.

Implements Filter.

bool getAcceptOnMatch ( ) const
bool getConvertInFixToPostFix ( ) const
LogString getExpression ( ) const
void setAcceptOnMatch ( bool  acceptOnMatch)
void setConvertInFixToPostFix ( bool  convertInFixToPostFix)
void setExpression ( const LogString expression)

The documentation for this class was generated from the following file: