我有这个log4j2.xml
- 配置文件。
如何制作过滤器以记录过滤器和Loglevel ERROR
中的所有指定标记?
在我的临时配置中它只记录指定的标记,但不记录ERROR
我该怎么做?
<Configuration status="warn" name="MyAppx" packages="">
<Appenders>
<RollingFile append="true" name="MyFile" fileName="/tmp/app.log" filePattern="/home/flex/logusb/app-%d{MM-dd-yyyy}-%i.log.gz">
<Filters>
<MarkerFilter marker="MARKER1" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="MARKER2" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="MARKER3" onMatch="ACCEPT" onMismatch="DENY"/
</Filters>
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} app %-5level %-30notEmpty{[%marker]} - %msg%xEx - %class{36} %L %M%n"/>
<Policies>
<!--<TimeBasedTriggeringPolicy />-->
<SizeBasedTriggeringPolicy size="20 MB"/>
</Policies>
<DefaultRolloverStrategy max="100"/>
</RollingFile>
</Appenders>
<Loggers>
<AsyncRoot level="INFO" includeLocation="true">
<AppenderRef ref="MyFile" />
</AsyncRoot>
</Loggers>
答案 0 :(得分:2)
尝试:
<Filters>
<MarkerFilter marker="MARKER1" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="MARKER2" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="MARKER3" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>