Apache Log4cxx Version 1.1.0
Loading...
Searching...
No Matches
log4cxx::filter::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...

#include <expressionfilter.h>

Inheritance diagram for log4cxx::filter::ExpressionFilter:
log4cxx::spi::Filter log4cxx::spi::OptionHandler log4cxx::helpers::Object

Public Member Functions

 ExpressionFilter ()
 
void activateOptions (helpers::Pool &p) override
 Activate the options that were previously set with calls to option setters.
 
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 override
 Returns log4cxx::spi::Filter#NEUTRAL is there is no string match.
 
- Public Member Functions inherited from log4cxx::spi::Filter
 Filter ()
 
 Filter (std::unique_ptr< FilterPrivate > priv)
 
virtual ~Filter ()
 
log4cxx::spi::FilterPtr getNext () const
 
void setNext (const log4cxx::spi::FilterPtr &newNext)
 
void activateOptions (helpers::Pool &p) override
 Activate the options that were previously set with calls to option setters.
 
void setOption (const LogString &option, const LogString &value) override
 Set option to value.
 
virtual FilterDecision decide (const LoggingEventPtr &event) const =0
 
- Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
 
virtual void activateOptions (helpers::Pool &p)=0
 Activate the options that were previously set with calls to option setters.
 
virtual void setOption (const LogString &option, const LogString &value)=0
 Set option to value.
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
 
virtual const helpers::ClassgetClass () const =0
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 

Additional Inherited Members

- Public Types inherited from log4cxx::spi::Filter
enum  FilterDecision { DENY = -1 , NEUTRAL = 0 , ACCEPT = 1 }
 

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

◆ ExpressionFilter()

log4cxx::filter::ExpressionFilter::ExpressionFilter ( )

Member Function Documentation

◆ activateOptions()

void log4cxx::filter::ExpressionFilter::activateOptions ( helpers::Pool p)
overridevirtual

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 log4cxx::spi::OptionHandler.

◆ decide()

FilterDecision log4cxx::filter::ExpressionFilter::decide ( const spi::LoggingEventPtr event) const
overridevirtual

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

Implements log4cxx::spi::Filter.

◆ getAcceptOnMatch()

bool log4cxx::filter::ExpressionFilter::getAcceptOnMatch ( ) const

◆ getConvertInFixToPostFix()

bool log4cxx::filter::ExpressionFilter::getConvertInFixToPostFix ( ) const

◆ getExpression()

LogString log4cxx::filter::ExpressionFilter::getExpression ( ) const

◆ setAcceptOnMatch()

void log4cxx::filter::ExpressionFilter::setAcceptOnMatch ( bool  acceptOnMatch)

◆ setConvertInFixToPostFix()

void log4cxx::filter::ExpressionFilter::setConvertInFixToPostFix ( bool  convertInFixToPostFix)

◆ setExpression()

void log4cxx::filter::ExpressionFilter::setExpression ( const LogString expression)

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