I am trying to encode my own RewritePolicy in Log4j2. The documentation states that:
RewritePolicy is an interface that allows implementations to validate and possibly modify LogEvents before they are passed to Appender. RewritePolicy declares one method called rewrite, which must be implemented. The method is passed by LogEvent and can return the same event or create a new one.
Here is my java class :
public final class MarkerInjectorRewritePolicy implements RewritePolicy { @Override public LogEvent rewrite(final LogEvent event) { final Marker marker = event.getMarker(); if (marker == null) return event;
Here is my yaml configuration file:
Rewrite: name: REWRITE_APPENDER AppenderRef: ref: ROUTING_APPENDER PropertiesRewritePolicy: Property: - name: foo value: bar
However, I have no idea how to insert it into the configuration file. How can I make it work at runtime?
java logging configuration log4j log4j2
Daniel Marcotte
source share