I\'m using log4j2 in my application.
What I want is everything up to \'debug\' to go to console, everything up to \'info\' to go to myapp.log, and ONLY \'info\' to g
You can use LevelRangeFilter. It has minLevel and maxLevel properties(and onMatch and onMismatch, ofcourse, too).
For example(in json) we need to print log in console only on info and warn levels:
"Appenders": {
"Console": {
"PatternLayout": {
"pattern": "%d{yyyy-MMM-dd HH:mm:ss a} [%t] %-5level %logger{36} - %msg%n"
},
"name": "Console",
"target": "SYSTEM_OUT",
"LevelRangeFilter": {
"minLevel": "warn",
"maxLevel": "info",
"onMatch": "ACCEPT",
"onMismatch": "DENY"
}
}
}
And if you want only info level then write "info" to both properties min and max.