繁体   English   中英

Java:更改外部库maven依赖项的日志级别

[英]Java: Change log level of external library maven dependency

我正在使用maven将外部依赖关系BrowserMob Proxy导入我的Java项目:

  <dependency> <groupId>net.lightbody.bmp</groupId> <artifactId>browsermob-core-littleproxy</artifactId> <version>2.1.0-beta-3</version> </dependency> 

但是,当我使用这个库时,它在DEBUG级别的输出中非常冗长,到了我几乎看不到我的程序正在做什么的程度。 如何减少此库生成的输出量? 我基本上看到了很多这样的事情:

[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Wrote: DefaultHttpContent(data: SimpleLeakAwareByteBuf(SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024))), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Not closing server connection on middle chunk for /renderer/vapi/current/v.js
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Not closing client connection on middle chunk for /renderer/vapi/current/v.js
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ProxyToServerConnection] (AWAITING_CHUNK) [id: 0x1e7ff722, L:/10.140.210.128:54478 - R:usweb.dotomi.com/23.215.104.50:80]: Reading: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Retaining reference counted message
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Writing: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Wrote: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Not closing server connection on middle chunk for /renderer/vapi/current/v.js
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Not closing client connection on middle chunk for /renderer/vapi/current/v.js
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ProxyToServerConnection] (AWAITING_CHUNK) [id: 0x1e7ff722, L:/10.140.210.128:54478 - R:usweb.dotomi.com/23.215.104.50:80]: Reading: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Retaining reference counted message
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Writing: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Wrote: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Not closing server connection on middle chunk for /renderer/vapi/current/v.js
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Not closing client connection on middle chunk for /renderer/vapi/current/v.js
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ProxyToServerConnection] (AWAITING_CHUNK) [id: 0x1e7ff722, L:/10.140.210.128:54478 - R:usweb.dotomi.com/23.215.104.50:80]: Reading: DefaultHttpContent(data: SlicedAbstractByteBuf(ridx: 0, widx: 1024, cap: 1024/1024, unwrapped: UnpooledUnsafeNoCleanerDirectByteBuf(ridx: 1024, widx: 1024, cap: 1024)), decoderResult: success)
[2018-04-09 15:04:40] [DEBUG] [LittleProxy-0-ProxyToServerWorker-1] [o.l.p.i.ClientToProxyConnection] (AWAITING_INITIAL) [id: 0x22000b92, L:/10.140.210.128:54435 - R:/10.140.210.128:54470]: Retaining reference counted message

这是一个与解决方案类似的问题。 这会满足您的需求吗? 它的工作原理是将System.out指向'/ dev / null'或文件(logFile),然后在完成后将其设置回控制台。

以下是问题的代码片段供参考:

PrintStream stdout = System.out;
System.setOut(new PrintStream(logFile));

// ...

System.setOut(stdout);  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM