Gradle:设置外部库中记录器的日志记录级别

时间:2018-06-01 12:26:52

标签: java logging gradle build.gradle slf4j

我正在使用Gradle 3.5运行我的Selenium测试。

在我将多个库更新到最新版本之前,我在控制台中遇到错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

更新后,错误消失了,但现在我在我的输出流中收到调试消息的声音:

15:08:00.594 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[0xda][0x17]ZC5[0xb8][0xac][0xbe]n2([0xa7][0xa8][0x16]?[0xd8][0xff][0xb5][0xf0][0xc1][0x82][0x92][0xe6]C[0xbe]{[0x7]H&[0xbd][0xe5][0xd2][.[0xbd][0xe5]%o[    0xa0]<H}[0x89][0xb7][0xdc]BI[0x97][0x9c][0xe4][0xd9]^nY[0x80]4[0x86][0xa9][0xcc][0x11][0x9e][0xb3]{O[0xe3]\Se[0x1][0x80]K[0x89][0xb7]<[0x83]Q5:_:[0x9a]e&Y@[0xfc]`?[0x9c][0xfe][0xf5][0x1]%_[0xb][0xb2][0x80]h[0xa8][0xd5]Y[    0xeb][0x92][0x1d][0x91][0xb3]%[0x90][0xfb]=[0x90][0xfe]3[0xa9][0xe0][0xdb][0x14][0x3])J[0xdc][0x8c]([0xf1]Ck_[0xe8][0xb1][0xb][0xb4][0xd0]rX[0xe5][0x9d]^n[0xe4][0xb1][0xc3][0x14]][0xb0]g[0xec][0x8a]<[0xc6][0x1c]0M[    0xb7]iJ0-[0xb][0xa6][0x8d]([0x11][0xf0]o[0xe2][0x9a][0xfc] [0xc9][0x97]z[0xad][0x8e][0x10][\r][0x11][0x7][0xab][0x87][0x97]Z]uJ[0xb8][0xc1]f[0x1c]![[0xb6][0xeb]w[0x84]h[0x1b]G[0x8][0xef][0xa9][0xc4][0x11][0xf2]pq[    0xfa][0xe1][0xf1]b4[0xdf][0x15]>[0xe3]V[0xe]p[0x84][0xf0][0x13][0xa4]#D:Bdjl:O[0xf8][0x1f][0xff][0x8d]Q[0xc9][0x11]b"[0x85][0x9f][0xde]h[0x86]1[0xd0][0xd8][0xd6]?7[0x9f][0xb7]B1r[0x1d]Q[0x80]fh[0x83][0x96]f[    0xf6][0xcd][0x98]6[0xc8][0xf][0xf6][0xef][0xdc]?[0x0][0xc8]n[0xd5]|[0xda] [0x80]I:B[0xa4]#D:B~[0xb7][0x8e][0x90][0x9e][0xd6]1[0xf2]*$[0xaa][0xb9]2bj[0xc]bj[0xa0][0xb2]r!9[0x9b][0xf7]t[0x9b][0xa6]J[0xdb][0x2][0x98][0x12]OH[    0x6][0xa4]j[0xf4][0x84]0[0x8]M[0x1c][0xcb][0xec][0xa0]*[0x9e][0xe6];[0x96]i[0xa8][0xd2][0x13][0x12][0xd8]7[0xf6]"[0x9]\[0xc9][0xc8][0x97],[0xcf][0xf4]/A[0xc1][0xae][0xe0][0x9][0xe9][0xa8][0xdd]<[0xf1][0xf8][0x2]J_[0xb2]#D5[0x8f]"[0xb7]rz    [0xd7][0xd8][0x94][9[0xb][0xa6][0x8d]xB[0xf8]7n}[0x9e][0x10]"
15:08:00.596 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "n/[0xf1][0x84][0xfc][0xfa][0xff][0x3][0x1c]`[0x94][0xf8]J[0xcd][0x3][0x0][\r][\n]"
15:08:00.596 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]"
15:08:00.596 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
15:08:00.597 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->https://api.github.com:443] can be kept alive indefinitely
15:08:00.598 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://api.github.com:443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
15:08:00.683 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Latest version of wires, geckodriver is 0.20.1
15:08:00.784 [main] INFO io.github.bonigarcia.wdm.Downloader - Using binary driver previously downloaded
15:08:00.786 [main] INFO io.github.bonigarcia.wdm.WebDriverManager - Exporting webdriver.gecko.driver as C:\Users\bnesteruk\.m2\repository\webdriver\geckodriver\win64\0.20.1\geckodriver.exe

据我所知,这些类中至少使用了两个Logger:

  • org.slf4j.Logger
  • org.apache.commons.logging.Log

我尝试根据https://docs.gradle.org/current/userguide/logging.html#sec:external_tools

设置gradle任务的日志记录级别
run {
    logging.captureStandardOutput LogLevel.INFO    
    doFirst {
 ...

但在这种情况下,控制台输出完全消失了。 即使我设置LogLevel.DEBUG

所以问题是:如何设置这些记录器的日志记录级别? 是否有可能在build.gradle中生成这个我需要某种配置文件?如果是这样,一个例子将非常感激。

0 个答案:

没有答案