Class ScriptFilter
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilter
org.apache.logging.log4j.core.filter.ScriptFilter
- All Implemented Interfaces:
Filter
,LifeCycle
,LifeCycle2
@Plugin(name="ScriptFilter",
category="Core",
elementType="filter",
printObject=true)
public final class ScriptFilter
extends AbstractFilter
Returns the onMatch result if the script returns True and returns the onMismatch value otherwise.
-
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
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 ScriptFilter
createFilter
(AbstractScript script, Filter.Result match, Filter.Result mismatch, Configuration configuration) Creates the ScriptFilter.Context Filter method.Appender Filter method.Appender Filter method.Appender Filter method.toString()
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
equalsImpl, filter, filter, filter, filter, filter, filter, filter, filter, filter, filter, 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
-
Method Details
-
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.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
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.
-
toString
- Overrides:
toString
in classAbstractFilter
-
createFilter
@PluginFactory public static ScriptFilter createFilter(@PluginElement("Script") AbstractScript script, @PluginAttribute("onMatch") Filter.Result match, @PluginAttribute("onMismatch") Filter.Result mismatch, @PluginConfiguration Configuration configuration) Creates the ScriptFilter.- Parameters:
script
- The script to run. The script must return a boolean value. Either script or scriptFile must be provided.match
- The action to take if a match occurs.mismatch
- The action to take if no match occurs.configuration
- the configuration- Returns:
- A ScriptFilter.
-