如何使用 log4j2 以编程方式禁用 netty 日志
How to disable netty logs programmatically using log4j2
如何在使用来自 ning.com 的 AsyncHttpClient 时使用 log4j2 以编程方式禁用 netty 日志 libraray.I 已经尝试了以下代码但没有工作。
我试过下面的代码
org.apache.logging.log4j.core.config.Configurator.setLevel(LogManager.getLogger("io.netty").getName(),org.apache.logging.log4j.Level.INFO);
您似乎只是想更改特定记录器的日志级别。如果那是你需要做的,你可以使用这样的代码:
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerCfg = config.getLoggerConfig("io.netty");
loggerCfg.setLevel(Level.OFF); //Using this level disables the logger.
ctx.updateLoggers();
如何在使用来自 ning.com 的 AsyncHttpClient 时使用 log4j2 以编程方式禁用 netty 日志 libraray.I 已经尝试了以下代码但没有工作。
我试过下面的代码
org.apache.logging.log4j.core.config.Configurator.setLevel(LogManager.getLogger("io.netty").getName(),org.apache.logging.log4j.Level.INFO);
您似乎只是想更改特定记录器的日志级别。如果那是你需要做的,你可以使用这样的代码:
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerCfg = config.getLoggerConfig("io.netty");
loggerCfg.setLevel(Level.OFF); //Using this level disables the logger.
ctx.updateLoggers();