0
我想用slf4j和log4j2創建自定義標記。下面是我如何生成的標記,並用它:如何在slf4j/log4j2中創建自定義標記?
Marker marker = org.slf4j.MarkerFactory.getMarker("WebService");
logger.info(marker, "service called");
而且下面是我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>
它創建的文件,但不寫任何東西給它。我錯過了什麼?謝謝