How do I set different logging level for package in json config of Log4j2 ? Here is my config (minus definition of appenders)
{
"configuration": {
"name": "Default2",
"loggers": {
"io.netty": {
"level": "info",
"appender-ref": [{
"ref": "Console"
}]
},
"root": {
"level": "debug",
"appender-ref": [{
"ref": "Console"
}, {
"ref": "File"
}]
}
}
}
}
it works with root
logger but fails when I add io.netty
with following error
2021-01-26 13:16:04,677 main ERROR Unable to locate plugin for io.netty
2021-01-26 13:16:18,132 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.config.LoggersPlugin for element loggers: java.lang.NullPointerException java.lang.NullPointerException
at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:258)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:622)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:695)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:712)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:267)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:245)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:664)
What am I missing ? Maybe log4j2 doesn't understand wildcard setting ?
question from:
https://stackoverflow.com/questions/65902171/different-logging-level-for-package-in-json-config-of-log4j2 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…