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 java.lang.Object implements RewritePolicy
This policy modifies events by replacing or possibly adding keys and values to the MapMessage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MapRewritePolicy.Mode
An enumeration to identify whether keys not in the MapMessage should be added or whether only existing keys should be updated.
-
Field Summary
Fields Modifier and Type Field Description protected static Logger
LOGGER
Allow subclasses access to the status logger without creating another instance.private java.util.Map<java.lang.String,java.lang.Object>
map
private MapRewritePolicy.Mode
mode
-
Constructor Summary
Constructors Modifier Constructor Description private
MapRewritePolicy(java.util.Map<java.lang.String,java.lang.Object> map, MapRewritePolicy.Mode mode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MapRewritePolicy
createPolicy(java.lang.String mode, KeyValuePair[] pairs)
The factory method to create the MapRewritePolicy.LogEvent
rewrite(LogEvent source)
Rewrite the event.java.lang.String
toString()
-
-
-
Field Detail
-
LOGGER
protected static final Logger LOGGER
Allow subclasses access to the status logger without creating another instance.
-
map
private final java.util.Map<java.lang.String,java.lang.Object> map
-
mode
private final MapRewritePolicy.Mode mode
-
-
Constructor Detail
-
MapRewritePolicy
private MapRewritePolicy(java.util.Map<java.lang.String,java.lang.Object> map, MapRewritePolicy.Mode mode)
-
-
Method Detail
-
rewrite
public LogEvent rewrite(LogEvent source)
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createPolicy
@PluginFactory public static MapRewritePolicy createPolicy(@PluginAttribute("mode") java.lang.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.
-
-