我正在3个不同的文件中捕获4个级别的日志。 DEBUG和INFO登录到fileA中,错误登录到fileB中,并且自定义级别SPLUNK(intValue 50)登录到FileC中。 FileA和FileB完美填充,但fileC没有填充。它同时包含ERROR和SPLUNK两个日志。如何仅捕获错误日志? 这就是我配置log4j2.xml文件的方式
<RollingFile name="App-Appender" fileName="${path}/EventManagerFramework.log" append = "true" filePattern="${path}/EventFramework_%d{yyyy-MM-dd}_%i.log">
<PatternLayout>
<Pattern>${log_Pattern}</Pattern>
</PatternLayout>
<ThresholdFilter level="WARN" onMatch="DENY" onMismatch="ACCEPT"/>
<Policies>
<TimeBasedTriggeringPolicy interval ="1" modulate="true" />
</Policies>
</RollingFile>
<RollingFile name="Test-Appender" fileName="${path}/EventManagerFramework_test.log" append = "true" filePattern="${path}/EventFramework_%d{yyyy-MM-dd}_%i.log">
<PatternLayout>
<Pattern>${log_Pattern}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval ="1" modulate="true" />
</Policies>
</RollingFile>
<RollingFile name="Error-Appender" fileName="${path}/EventManagerFramework_error.log" append = "true" filePattern="${path}/EventFramework_error_%d{yyyy-MM-dd}_%i.log" >
<PatternLayout>
<Pattern>${log_Pattern}</Pattern>
</PatternLayout>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY" />
<Policies>
<TimeBasedTriggeringPolicy interval ="1" modulate="true" />
</Policies>
</RollingFile>
<RollingFile name="Splunk-Appender" fileName="${path}/EventManagerFramework_splunk.log" append = "true" filePattern="${path}/EventFramework_splunk_%d{yyyy-MM-dd}_%i.log">
<PatternLayout>
<Pattern>${log_Pattern}</Pattern>
</PatternLayout>
<ThresholdFilter level="SPLUNK" onMatch="ACCEPT" onMismatch="DENY" />
<ThresholdFilter level="ERROR" onMatch="DENY" />
<Policies>
<TimeBasedTriggeringPolicy interval ="1" modulate="true" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.springframework.web" level="debug" additivity="false">
<AppenderRef ref="SpringBoot-Appender"/>
</Logger>
<Logger name="com.adp.is.ISEventManager" level="debug" additivity="false">
<AppenderRef ref="Test-Appender"/>
</Logger>
<Logger name="com.adp.is.event" level="debug" additivity="false">
<AppenderRef ref="App-Appender"/>
<AppenderRef ref="Splunk-Appender"/>
<AppenderRef ref="Error-Appender" />
</Logger>
<Logger name="org.springframework.web" level="error" additivity="false">
<AppenderRef ref="Error-Appender"/>
</Logger>
<Root>
<AppenderRef ref="Console-Appender"/>
</Root>
</Loggers>