down votefavorite
<https://stackoverflow.com/questions/36018016/how-to-create-the-custom-marker-in-slf4j-log4j2#>
I am trying to create custom marker using slf4j and log4j2. Below is how I
created the marker and used it:
Marker marker =
org.slf4j.MarkerFactory.getMarker("WebService");logger.info(marker,
"service called");
And below is my log4j2-test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Properties>
<Property name="layout">%d | %-5p | [%t] | %c{2} | %M | %m%n</Property>
</Properties>
<Appenders>
<File name="WebServices"
fileName="${sys:user.home}/logs/service_requests.log">
<MarkerFilter marker="WebService" onMatch="ACCEPT"
onMismatch="DENY" />
<JSONLayout>
</JSONLayout>
</File>
</Appenders>
<Loggers>
<Root level="TRACE">
<AppenderRef ref="WebServices" level="INFO" />
</Root>
</Loggers>
</Configuration>
It created the file but does not write anything to it. Did I miss
something? thank you