在使用java的web3j库时,http访问会输出较多如下的日志内容,严重影响终端的其他输出信息。
14:26:48.572 [main] DEBUG org.web3j.protocol.http.HttpService - <-- END HTTP (40-byte body)
14:26:48.588 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - --> POST http://192.168.56.118:8545/
14:26:48.588 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - Content-Type: application/json; charset=utf-8
14:26:48.588 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - Content-Length: 60
14:26:48.588 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService -
14:26:48.588 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - {"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}
14:26:48.589 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - --> END POST (60-byte body)
14:26:48.590 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - <-- 200 OK http://192.168.56.118:8545/ (1ms)
14:26:48.590 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - Content-Type: application/json
14:26:48.590 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - Vary: Origin
14:26:48.591 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - Date: Wed, 02 Dec 2020 06:26:48 GMT
14:26:48.591 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService -
14:26:48.595 [pool-1-thread-1] DEBUG org.web3j.protocol.http.HttpService - {"jsonrpc":"2.0","id":1,"result":"0x1"}
如何关闭:已maven项目为例,在/src/main/resources/目录下,创建logback.xml文件即可搞定,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- Change to DEBUG to log protocol messages -->
<logger name="org.web3j.protocol" level="INFO"/>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
版权声明:本文为xiongyangg原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。