How to set threshold value for ConsoleAppender in new log4j2 using xml file. Usually we do it in log4j 1.x in the below way.
Ref link: Log4j - priority value and param name concept explanation
How to set it in log4j 2.x ?
How to set threshold value for ConsoleAppender in new log4j2 using xml file. Usually we do it in log4j 1.x in the below way.
Ref link: Log4j - priority value and param name concept explanation
How to set it in log4j 2.x ?
You can set a log level on the AppenderRef:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%m%n"/>
</Console>
<File name="MyFile" fileName="logs/app.log">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="STDOUT" level="warn"/>
<AppenderRef ref="MyFile"/>
</Root>
</Loggers>
</Configuration>
You can use filter to replace the
<param name="Threshold" value="trace" />
with
<Filter type="ThresholdFilter" level="trace"/>