Class ScriptPatternSelector
java.lang.Object
org.apache.logging.log4j.core.layout.ScriptPatternSelector
- All Implemented Interfaces:
LocationAware
,PatternSelector
@Plugin(name="ScriptPatternSelector",
category="Core",
elementType="patternSelector",
printObject=true)
public class ScriptPatternSelector
extends Object
implements PatternSelector, LocationAware
Selects the pattern to use based on the result of executing a Script. The returned value will be used as the "key"
to choose between one of the configured patterns. If no key is returned or there is no match the default
pattern will be used.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Custom ScriptPatternSelector builder. -
Field Summary
Fields inherited from interface org.apache.logging.log4j.core.layout.PatternSelector
ELEMENT_TYPE
-
Constructor Summary
ConstructorDescriptionScriptPatternSelector
(AbstractScript script, PatternMatch[] properties, String defaultPattern, boolean alwaysWriteExceptions, boolean disableAnsi, boolean noConsoleNoAnsi, Configuration config) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScriptPatternSelector
createSelector
(AbstractScript script, PatternMatch[] properties, String defaultPattern, boolean alwaysWriteExceptions, boolean noConsoleNoAnsi, Configuration configuration) Deprecated.UsenewBuilder()
instead.getFormatters
(LogEvent event) Creates a builder for a custom ScriptPatternSelector.boolean
toString()
-
Constructor Details
-
ScriptPatternSelector
@Deprecated public ScriptPatternSelector(AbstractScript script, PatternMatch[] properties, String defaultPattern, boolean alwaysWriteExceptions, boolean disableAnsi, boolean noConsoleNoAnsi, Configuration config) Deprecated.UsenewBuilder()
instead. This will be private in a future version.
-
-
Method Details
-
requiresLocation
public boolean requiresLocation()- Specified by:
requiresLocation
in interfaceLocationAware
-
getFormatters
- Specified by:
getFormatters
in interfacePatternSelector
-
newBuilder
Creates a builder for a custom ScriptPatternSelector.- Returns:
- a ScriptPatternSelector builder.
-
createSelector
@Deprecated public static ScriptPatternSelector createSelector(AbstractScript script, PatternMatch[] properties, String defaultPattern, boolean alwaysWriteExceptions, boolean noConsoleNoAnsi, Configuration configuration) Deprecated.UsenewBuilder()
instead.Deprecated, usenewBuilder()
instead.- Parameters:
script
- the scriptproperties
- the PatternMatch configuration itemsdefaultPattern
- the default patternalwaysWriteExceptions
- To always write exceptions even if the pattern contains no exception conversions.noConsoleNoAnsi
- Do not output ANSI escape codes if System.console() is null.configuration
- the configuration- Returns:
- a new ScriptPatternSelector
-
toString
-
newBuilder()
instead.