Reputation: 2255
I have this log4j2.xml
-Configuration file.
How can I make a filter to log all the Specified markers in the Filter AND Loglevel ERROR
?
In my curent configuration it only logs the Specified Markers but not ERROR
s how could I do that?
<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>
Upvotes: 1
Views: 1968
Reputation: 847
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>
Upvotes: 2