gpt4 book ai didi

java - 用于标记和日志级别的 log4j2 过滤器

转载 作者:行者123 更新时间:2023-12-02 02:54:02 28 4
gpt4 key购买 nike

我有这个log4j2.xml-配置文件。如何创建一个过滤器来记录过滤器中所有指定的标记和日志级别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>

最佳答案

尝试:

<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>

关于java - 用于标记和日志级别的 log4j2 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43387219/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com