如何关闭Netty库调试输出?

我正在使用Netty(通过Ning异步HTTP 库 )通过HTTP检索文档。 这会在控制台上产生大量的调试输出,如下面列出的单个文档请求。

任何人都知道如何关闭它? 我真的不需要看到这个输出。

我打电话给Scala,如果这有任何区别的话。

15:07:14.273 [run-main] DEBUG cnhcpnNettyAsyncHttpProvider - Non cached request DefaultHttpRequest(chunked: false) GET /api/search.json?q=foo HTTP/1.1 Host: www.documentcloud.org Connection: keep-alive Accept: */* User-Agent: NING/1.0 using Channel [id: 0x2839ca40] 15:07:14.930 [New I/O client worker #1-1] DEBUG cnhcpnNettyAsyncHttpProvider - Request DefaultHttpRequest(chunked: false) GET /api/search.json?q=foo HTTP/1.1 Host: www.documentcloud.org Connection: keep-alive Accept: */* User-Agent: NING/1.0 Response DefaultHttpResponse(chunked: true) HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Content-Length: 10477 Connection: keep-alive Vary: Accept-Encoding Status: 200 X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.13 ETag: "4f8f766d639dd84d014dfee3abb45de2" X-Runtime: 611 Cache-Control: private, max-age=0, must-revalidate Server: nginx/1.2.1 + Phusion Passenger 3.0.13 (mod_rails/mod_rack) 15:07:14.941 [New I/O client worker #1-1] DEBUG cnhcpnetty.NettyConnectionsPool - Adding uri: http://www.documentcloud.org:80 for channel [id: 0x2839ca40, /10.5.165.61:56133 => www.documentcloud.org/75.101.159.206:80] 15:07:16.921 [New I/O client worker #1-1] DEBUG cnhcpnNettyAsyncHttpProvider - Channel Closed: [id: 0x2839ca40, /10.5.165.61:56133 :> www.documentcloud.org/75.101.159.206:80] with attachment com.ning.http.client.providers.netty.NettyAsyncHttpProvider$DiscardEvent@63182c3d 15:08:13.924 [Timer-0] DEBUG cnhcpnetty.NettyConnectionsPool - Entry count for : http://www.documentcloud.org:80 : 0 

通过缩写的包名来判断,似乎我在这里使用slf4j / logback进行日志记录。 在这种情况下,只需尝试在类路径中包含logback.xml配置文件。 一些东西

     %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n        

上面的xml会导致com.ning.http.client(和向下)下的任何内容只省略警告,更糟糕的是输出,它将被流式传输到system.out。 其他任何东西都会忽略INFO +你可以在这里找到有关配置logback的更多信息: http : //logback.qos.ch/manual/configuration.html

我知道一个旧问题的延迟发布但我最近不得不关闭来自netty的令人讨厌的重复INFO级别日志记录:

 [main] INFO com.ning.http.client.providers.netty.NettyAsyncHttpProvider - Number of application's worked threads is 16 

在我的情况下,我需要以编程方式禁用它。 查看slf4j org.slf4j.impl.SimpleLogger(netty调用的logger外观)我发现了一种简单的方法来控制自己的启动代码中所有SimpleLogger实例的默认slf4j日志级别:

 System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "warn"); 

或者只是我感兴趣的记录器实例:

 System.setProperty(SimpleLogger.LOG_KEY_PREFIX + "com.ning.http.client", "warn"); 

该值可以是“trace”,“debug”,“info”,“warn”或“error”中的任何一个,默认值为“info”。