我想根据某些条件将turboFilter添加为
java代码
private static final Marker nfrMarker = MarkerFactory.getMarker("NFR");
private static final Logger logger = LoggerFactory.getLogger(LogbackFilteringDemoApplication.class);
logger.info(nfrMarker,"nfrMarker message one");
logger.info("message two");
logger.info(nfrMarker, "nfrMarker message three");
logger.info("message four");
logger.info(nfrMarker, "nfrMarker message five");
logger.info("message six");
logger.info(nfrMarker, "nfrMarker message six");
logback.xml代码段
<if condition='property("application.prop").equals("do")'>
<then>
<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
<Marker>NFR</Marker>
<onMatch>ACCEPT</onMatch>
</turboFilter>
</then>
<else>
<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
<Marker>NFR</Marker>
<onMatch>DENY</onMatch>
</turboFilter>
</else>
</if>
....
但是它不起作用。
甚至尝试过这种组合
<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
<Marker>NFR</Marker>
<if condition='property("application.prop").equals("do")'>
<then>
<onMatch>ACCEPT</onMatch>
</then>
<else>
<onMatch>DENY</onMatch>
</else>
</if>
</turboFilter>
但没有帮助。
使用的依赖项
logback-classic version 1.2.3
org.codehaus.janino version 3.0.8
输出
13-08-2018 13:06:33.644 [35m[main][0;39m [34mINFO [0;39m c.s.l.LogbackFilteringDemoApplication.main - message two
13-08-2018 13:06:33.647 [35m[main][0;39m [34mINFO [0;39m c.s.l.LogbackFilteringDemoApplication.main - message four
13-08-2018 13:06:33.647 [35m[main][0;39m [34mINFO [0;39m c.s.l.LogbackFilteringDemoApplication.main - message six
nfrMarker日志根本不可见!