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



我正在使用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);  

相关内容

  • 没有找到相关文章

最新更新