2017-04-18 132 views
0

如何禁用,而使用從ning.com libraray.I AsyncHttpClient曾嘗試下面的代碼,但不工作編程方式使用log4j2網狀日誌禁用網狀日誌。如何以編程方式使用log4j2

我曾嘗試下面的代碼

org.apache.logging.log4j.core.config.Configurator.setLevel(LogManager.getLogger("io.netty").getName(),org.apache.logging.log4j.Level.INFO); 

回答

0

看起來你只是想更改特定記錄器的日誌級別。如果這是你需要做的,你可以使用這樣的代碼:

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(); 
+0

我想禁用網狀日誌完全 – cuser1

+0

好了級別設置爲OFF –