Class LevelRangeFilter
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilter
org.apache.logging.log4j.core.filter.LevelRangeFilter
- All Implemented Interfaces:
Filter
,LifeCycle
,LifeCycle2
@Plugin(name="LevelRangeFilter",
category="Core",
elementType="filter",
printObject=true)
public final class LevelRangeFilter
extends AbstractFilter
This filter returns the
AbstractFilter.onMatch
result if the level of the LogEvent
is in the range of the configured minLevel
and maxLevel
values, otherwise it returns the AbstractFilter.onMismatch
result.
The default values for minLevel
and maxLevel
are set to Level.OFF
and Level.ALL
, respectively.
The default values for AbstractFilter.onMatch
and AbstractFilter.onMismatch
are set to Filter.Result.NEUTRAL
and Filter.Result.DENY
, respectively.
The levels get compared by their associated integral values; Level.OFF
has an integral value of 0, Level.FATAL
100, Level.ERROR
200, and so on.
For example, if the filter is configured with maxLevel
set to Level.INFO
, the filter will return AbstractFilter.onMismatch
result for LogEvent
s of level with higher integral values; Level.DEBUG
, Level.TRACE
, etc.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
AbstractFilter.AbstractFilterBuilder<B extends AbstractFilter.AbstractFilterBuilder<B>>
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.Filter
Filter.Result
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Level
THe default maximum level threshold.static final Level
The default minimum level threshold.static final Filter.Result
The default result on a match.static final Filter.Result
The default result on a mismatch.Fields inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
onMatch, onMismatch
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Fields inherited from interface org.apache.logging.log4j.core.Filter
ELEMENT_TYPE, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionstatic LevelRangeFilter
createFilter
(Level minLevel, Level maxLevel, Filter.Result onMatch, Filter.Result onMismatch) Creates an instance with the provided properties.Context Filter method.Appender Filter method.Appender Filter method.Appender Filter method.Appender Filter method.Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) Appender Filter method.Appender Filter method.toString()
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
equalsImpl, getOnMatch, getOnMismatch, hashCodeImpl
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
getState, getStatusLogger, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop, stop
-
Field Details
-
DEFAULT_MIN_LEVEL
The default minimum level threshold. -
DEFAULT_MAX_LEVEL
THe default maximum level threshold. -
DEFAULT_ON_MATCH
The default result on a match. -
DEFAULT_ON_MISMATCH
The default result on a mismatch.
-
-
Method Details
-
createFilter
@PluginFactory public static LevelRangeFilter createFilter(@PluginAttribute("minLevel") Level minLevel, @PluginAttribute("maxLevel") Level maxLevel, @PluginAttribute("onMatch") Filter.Result onMatch, @PluginAttribute("onMismatch") Filter.Result onMismatch) Creates an instance with the provided properties.- Parameters:
minLevel
- the minimum level thresholdmaxLevel
- the maximum level thresholdonMatch
- the result to return on a matchonMismatch
- the result to return on a mismatch- Returns:
- a new instance
-
filter
Description copied from class:AbstractFilter
Context Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
event
- The LogEvent.- Returns:
- The Result of filtering.
-
filter
Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.t
- A throwable or null.- Returns:
- The Result of filtering.
-
filter
Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.t
- A throwable or null.- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.params
- An array of parameters or null.- Returns:
- The Result of filtering.
-
filter
Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parametersp7
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parametersp7
- the message parametersp8
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parametersp7
- the message parametersp8
- the message parametersp9
- the message parameters- Returns:
- The Result of filtering.
-
getMinLevel
- Returns:
- the minimum level threshold
-
getMaxLevel
- Returns:
- the maximum level threshold
-
toString
- Overrides:
toString
in classAbstractFilter
-