Class LevelRangeFilter
- java.lang.Object
-
- org.apache.log4j.spi.Filter
-
- org.apache.log4j.filter.LevelRangeFilter
-
- All Implemented Interfaces:
org.apache.log4j.spi.OptionHandler
public class LevelRangeFilter extends org.apache.log4j.spi.FilterThis is a very simple filter based on level matching, which can be used to reject messages with priorities outside a certain range.The filter admits three options LevelMin, LevelMax and AcceptOnMatch.
If the level of the
LoggingEventis not between Min and Max (inclusive), thenFilter.DENYis returned.If the Logging event level is within the specified range, then if AcceptOnMatch is true,
Filter.ACCEPTis returned, and if AcceptOnMatch is false,Filter.NEUTRALis returned.If
LevelMinis not defined, then there is no minimum acceptable level (ie a level is never rejected for being too "low"/unimportant). IfLevelMaxis not defined, then there is no maximum acceptable level (ie a level is never rejected for beeing too "high"/important).Refer to the
setThresholdmethod available toallappenders extendingAppenderSkeletonfor a more convenient way to filter out events by level.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleanacceptOnMatchDo we return ACCEPT when a match occurs.(package private) org.apache.log4j.LevellevelMax(package private) org.apache.log4j.LevellevelMin
-
Constructor Summary
Constructors Constructor Description LevelRangeFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intdecide(org.apache.log4j.spi.LoggingEvent event)Return the decision of this filter.booleangetAcceptOnMatch()Get the value of theAcceptOnMatchoption.org.apache.log4j.LevelgetLevelMax()Get the value of theLevelMaxoption.org.apache.log4j.LevelgetLevelMin()Get the value of theLevelMinoption.voidsetAcceptOnMatch(boolean acceptOnMatch)Set theAcceptOnMatchoption.voidsetLevelMax(org.apache.log4j.Level levelMax)Set theLevelMaxoption.voidsetLevelMin(org.apache.log4j.Level levelMin)Set theLevelMinoption.
-
-
-
Method Detail
-
decide
public int decide(org.apache.log4j.spi.LoggingEvent event)
Return the decision of this filter.- Specified by:
decidein classorg.apache.log4j.spi.Filter
-
getLevelMax
public org.apache.log4j.Level getLevelMax()
Get the value of theLevelMaxoption.
-
getLevelMin
public org.apache.log4j.Level getLevelMin()
Get the value of theLevelMinoption.
-
getAcceptOnMatch
public boolean getAcceptOnMatch()
Get the value of theAcceptOnMatchoption.
-
setLevelMax
public void setLevelMax(org.apache.log4j.Level levelMax)
Set theLevelMaxoption.
-
setLevelMin
public void setLevelMin(org.apache.log4j.Level levelMin)
Set theLevelMinoption.
-
setAcceptOnMatch
public void setAcceptOnMatch(boolean acceptOnMatch)
Set theAcceptOnMatchoption.
-
-