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
Nested ClassesModifier and TypeClassDescriptionstatic class
Custom ScriptPatternSelector builder. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configuration
private final PatternFormatter[]
private final String
private final Map
<String, PatternFormatter[]> private static Logger
private final boolean
private final AbstractScript
Fields inherited from interface org.apache.logging.log4j.core.layout.PatternSelector
ELEMENT_TYPE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ScriptPatternSelector
(Configuration config, AbstractScript script, PatternMatch[] properties, String defaultPattern, boolean alwaysWriteExceptions, boolean disableAnsi, boolean noConsoleNoAnsi) ScriptPatternSelector
(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()
-
Field Details
-
formatterMap
-
patternMap
-
defaultFormatters
-
defaultPattern
-
LOGGER
-
script
-
configuration
-
requiresLocation
private final boolean requiresLocation
-
-
Constructor Details
-
ScriptPatternSelector
private ScriptPatternSelector(Configuration config, AbstractScript script, PatternMatch[] properties, String defaultPattern, boolean alwaysWriteExceptions, boolean disableAnsi, boolean noConsoleNoAnsi) -
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
-properties
-defaultPattern
-alwaysWriteExceptions
-noConsoleNoAnsi
-configuration
-- Returns:
- a new ScriptPatternSelector
-
toString
-
newBuilder()
instead.