Class MapRewritePolicy
java.lang.Object
org.apache.logging.log4j.core.appender.rewrite.MapRewritePolicy
- All Implemented Interfaces:
RewritePolicy
@Plugin(name="MapRewritePolicy",
category="Core",
elementType="rewritePolicy",
printObject=true)
public final class MapRewritePolicy
extends Object
implements RewritePolicy
This policy modifies events by replacing or possibly adding keys and values to the MapMessage.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enumeration to identify whether keys not in the MapMessage should be added or whether only existing keys should be updated. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MapRewritePolicy
createPolicy
(String mode, KeyValuePair[] pairs) The factory method to create the MapRewritePolicy.Rewrite the event.toString()
-
Field Details
-
LOGGER
Allow subclasses access to the status logger without creating another instance.
-
-
Method Details
-
rewrite
Rewrite the event.- Specified by:
rewrite
in interfaceRewritePolicy
- Parameters:
source
- a logging event that may be returned or used to create a new logging event.- Returns:
- The LogEvent after rewriting.
-
toString
-
createPolicy
@PluginFactory public static MapRewritePolicy createPolicy(@PluginAttribute("mode") String mode, @PluginElement("KeyValuePair") KeyValuePair[] pairs) The factory method to create the MapRewritePolicy.- Parameters:
mode
- The string representation of the Mode.pairs
- key/value pairs for the new Map keys and values.- Returns:
- The MapRewritePolicy.
-