[英]How to disable log4j logging in Http Client 4.1 to log to FileAppender
这是我的HTTP客户端的log4j配置:
log4j.appender.HTTPCLIENT_APPDR=com.xxx.log.FileAppender
log4j.appender.HTTPCLIENT_APPDR.File=${user.dir}/log/access.log
log4j.appender.HTTPCLIENT_APPDR.layout=org.apache.log4j.PatternLayout
log4j.appender.HTTPCLIENT_APPDR_APPDR.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss SSS}ms %-5p [%t] - %m%n
log4j.appender.HTTPCLIENT_APPDR.MaxFileSize=20000KB
log4j.appender.HTTPCLIENT_APPDR.MaxBackupIndex=30
log4j.logger.org.apache.http=DEBUG,HTTPCLIENT_APPDR
我希望它根据我所处的环境关闭来自CODE的httpclient
日志记录(我知道如何从log4j.properties中禁用它)。
我尝试插入这些行:
+ System.setProperty("log4j.logger.org.apache.http", "ERROR");
要么
+ Logger.getLogger("log4j.logger.org.apache.http").setLevel(Level.off)
在我的应用程序的开始但它不起作用。
Can I access the log4j properties from the System class? When I look at the Logger.getLogger("log4j.logger.org.apache.http")
the level is null? Should it not be DEBUG? What worked finally,
Can I access the log4j properties from the System class? When I look at the Logger.getLogger("log4j.logger.org.apache.http")
the level is null? Should it not be DEBUG? What worked finally,
Can I access the log4j properties from the System class? When I look at the
Logger.getLogger("log4j.logger.org.apache.http")
the level is null? Should it not be DEBUG? What worked finally,
Logger.getLogger("org.apache.http").setLevel(org.apache.log4j.Level.OFF);
我没有使用正确的密钥。
问候,
什么最终起作用,Logger.getLogger(“org.apache.http”)。setLevel(org.apache.log4j.Level.OFF); 我没有使用正确的密钥。
如果您有log4j.properties文件,请添加此行
log4j.logger.org.apache.http=WARN
这只在Apache HttpClient 4中测试过
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.