簡體   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