AFAIK the logger level for a package/class in log4j2 properties file should be set like below.
loggers = abc
logger.abc.name = com.abc.MyClass
logger.abc.level = INFO
So if I have 50 classes/packages to specify, does it mean I have to have 50 entries in loggers
and 50 of entries for each name
and level
.
Is not there an alternative way to do it with one line for each logger so it can be done in 50 lines?
You can specify the logging... for each package. Like this:
logger.mongodb.name = org.mongodb.driver
logger.mongodb.level = warn
logger.ehcache.name = org.ehcache.core
logger.ehcache.level = warn
In the name you can put a package (or subpackage), you don't need to specify specific class name; unless you want specific configuration for that class obviously.
Also, you can specify default configuration for all classes that do not fall in specific configurations (rootLogger).
Look for "Configuration with Properties" section in here for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With