Log4j 1.1b7

org.apache.log4j.varia
Class PriorityRangeFilter

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

public class PriorityRangeFilter
extends Filter

This is a very simple filter based on priority matching, which can be used to reject messages with priorities outside a certain range.

The filter admits three options PriorityMin, PriorityMax and AcceptOnMatch.

If the priority of the LoggingEvent is not between Min and Max (inclusive), then Filter.DENY is returned.

If the Logging event priority is within the specified range, then if AcceptOnMatch is true, Filter.ACCEPT is returned, and if AcceptOnMatch is false, Filter.NEUTRAL is returned.

If PriorityMinw is not defined, then there is no minimum acceptable priority (ie a priority is never rejected for being too "low"/unimportant). If PriorityMax is not defined, then there is no maximum acceptable priority (ie a priority is never rejected for beeing too "high"/important).

Refer to the setThreshold method available to all appenders extending AppenderSkeleton for a more convenient way to filter out events by priority.

Author:
Simon Kitching, based on code by Ceki Gülcü

Field Summary
static String ACCEPT_ON_MATCH_OPTION
          See class comments
static String PRIORITY_MAX_OPTION
          See class comments
static String PRIORITY_MIN_OPTION
          See class comments
 
Fields inherited from class org.apache.log4j.spi.Filter
ACCEPT, DENY, NEUTRAL, next
 
Constructor Summary
PriorityRangeFilter()
           
 
Method Summary
 int decide(LoggingEvent event)
          Return the decision of this filter.
 boolean getAcceptOnMatch()
          Get the value of the AcceptOnMatch option.
 String[] getOptionStrings()
          Return list of strings that the OptionHandler instance recognizes.
 Priority getPriorityMax()
          Get the value of the PriorityMax option.
 Priority getPriorityMin()
          Get the value of the PriorityMin option.
 void setAcceptOnMatch(boolean acceptOnMatch)
          Set the AcceptOnMatch option.
 void setOption(String key, String value)
          Set option to value.
 void setPriorityMax(Priority priorityMax)
          Set the PriorityMax option.
 void setPriorityMin(Priority priorityMin)
          Set the PriorityMin option.
 
Methods inherited from class org.apache.log4j.spi.Filter
activateOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIORITY_MIN_OPTION

public static final String PRIORITY_MIN_OPTION
See class comments

PRIORITY_MAX_OPTION

public static final String PRIORITY_MAX_OPTION
See class comments

ACCEPT_ON_MATCH_OPTION

public static final String ACCEPT_ON_MATCH_OPTION
See class comments
Constructor Detail

PriorityRangeFilter

public PriorityRangeFilter()
Method Detail

decide

public int decide(LoggingEvent event)
Return the decision of this filter.
Overrides:
decide in class Filter
Following copied from class: org.apache.log4j.spi.Filter
Parameters:
event - The LoggingEvent to decide upon.
decision - The decision of the filter.

getPriorityMax

public Priority getPriorityMax()
Get the value of the PriorityMax option.

getPriorityMin

public Priority getPriorityMin()
Get the value of the PriorityMin option.

getAcceptOnMatch

public boolean getAcceptOnMatch()
Get the value of the AcceptOnMatch option.

setPriorityMax

public void setPriorityMax(Priority priorityMax)
Set the PriorityMax option.

setPriorityMin

public void setPriorityMin(Priority priorityMin)
Set the PriorityMin option.

setAcceptOnMatch

public void setAcceptOnMatch(boolean acceptOnMatch)
Set the AcceptOnMatch option.

getOptionStrings

public String[] getOptionStrings()
Deprecated. We now use JavaBeans introspection to configure components.

Description copied from interface: OptionHandler
Return list of strings that the OptionHandler instance recognizes.

setOption

public void setOption(String key,
                      String value)
Deprecated. We now use JavaBeans introspection to configure components.

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 1.1b7

Please notify me about new log4j releases.