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 classCustom ScriptPatternSelector builder. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Configurationprivate final PatternFormatter[]private final Stringprivate final Map<String, PatternFormatter[]> private static Loggerprivate final booleanprivate final AbstractScriptFields inherited from interface org.apache.logging.log4j.core.layout.PatternSelector
ELEMENT_TYPE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateScriptPatternSelector(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 ScriptPatternSelectorcreateSelector(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.booleantoString()
-
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:
requiresLocationin interfaceLocationAware
-
getFormatters
- Specified by:
getFormattersin 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.