简体   繁体   English

标记和对数级别的log4j2过滤器

[英]log4j2 filter for Marker and Loglevel

I have this log4j2.xml -Configuration file. 我有此log4j2.xml配置文件。 How can I make a filter to log all the Specified markers in the Filter AND Loglevel ERROR ? 如何制作过滤器以记录“过滤器和日志级别ERROR中的所有指定标记? In my curent configuration it only logs the Specified Markers but not ERROR s how could I do that? 在我当前的配置中,它仅记录指定标记,而不记录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>

Try: 尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM