Log4j 0.9.1

org.log4j.varia
Class StringMatchFilter

java.lang.Object
  |
  +--org.log4j.spi.Filter
        |
        +--org.log4j.varia.StringMatchFilter
All Implemented Interfaces:
OptionHandler

public class StringMatchFilter
extends Filter

This is a very simple filter based on string matching.

The filter admits two options StringToMatch and AcceptOnMatch. If there is a match between the value of the StringToMatch option and the message of the LoggingEvent, then the decide(org.log4j.spi.LoggingEvent) method returns Filter.ACCEPT if the AcceptOnMatch option value is true, if it is false then Filter.DENY is returned. If there is no match, Filter.NEUTRAL is returned.

See configuration files test6.xml, test7.xml, test8.xml, test9.xml, and test10.xml for examples of seeting up a StringMatchFilter.

Since:
0.9.0
Author:
Ceki Gülcü

Field Summary
static String ACCEPT_ON_MATCH_OPTION
           
static String STRING_TO_MATCH_OPTION
           
 
Fields inherited from class org.log4j.spi.Filter
ACCEPT, DENY, NEUTRAL, next
 
Constructor Summary
StringMatchFilter()
           
 
Method Summary
 int decide(LoggingEvent event)
          Returns Filter.NEUTRAL is there is no string match.
 String[] getOptionStrings()
          Return list of strings that the OptionHandler instance recognizes.
 void setOption(String key, String value)
          Set option to value.
 
Methods inherited from class org.log4j.spi.Filter
activateOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_TO_MATCH_OPTION

public static final String STRING_TO_MATCH_OPTION

ACCEPT_ON_MATCH_OPTION

public static final String ACCEPT_ON_MATCH_OPTION
Constructor Detail

StringMatchFilter

public StringMatchFilter()
Method Detail

decide

public int decide(LoggingEvent event)
Returns Filter.NEUTRAL is there is no string match.
Overrides:
decide in class Filter
Following copied from class: org.log4j.spi.Filter
Parameters:
event - The LoggingEvent to decide upon.
decision - The decision of the filter.

getOptionStrings

public String[] getOptionStrings()
Description copied from interface: OptionHandler
Return list of strings that the OptionHandler instance recognizes.

setOption

public void setOption(String key,
                      String value)
Description copied from interface: OptionHandler
Set option to value.

The handling of each option depends on the OptionHandler instance. Some options may become active immediately whereas other may be activated only when OptionHandler.activateOptions() is called.


Log4j 0.9.1

Please notify me about new log4j releases.