How to disable log4j debug-logging for http-api of com.spotify.docker-client

557 Views Asked by At

Using log4j 1.2.17 and com.spotify.docker-client 6.1.1 in Java8. If i set log4j root log level in DEBUG, then http-api of docker client write in log many messages like

09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:113 - http-outgoing-13 << HTTP/1.1 200 OK
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Api-Version: 1.37
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Docker-Experimental: false
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Ostype: linux
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Server: Docker/18.03.1-ce (linux)
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Date: Thu, 04 Oct 2018 06:42:50 GMT
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Content-Type: text/plain; charset=utf-8
09:42:50,624 DEBUG jersey-client-async-executor-0 headers:onResponseReceived:116 - http-outgoing-13 << Transfer-Encoding: chunked

I don`t understand how to disable it. All my tries:

log4j.rootLogger=DEBUG, stdout
log4j.logger.jersey-client-async-executor-0=INFO
log4j.logger.com.sun.jersey=INFO
log4j.logger.com.spotify=INFO

And this doesn't stop it. How can i disable DEBUG-loggin of jersey-client-async-executor-0 ? Thanks.

2

There are 2 best solutions below

0
On

You are setting the log level to Debug and then you are logging on the logger the jersey-client, thus it is getting set on Debug level as well.

Either set your rootlogger to a different level or dont add the jersey-client to the logger.

0
On

In log4j all the user defined loggers inherit from their parents and all loggers are either direct or indirect child of the rootLogger.

In order to stop your logger to inherit from a parent add this to your code:

log4j.additivity.jersey-client-async-executor-0=false

this will allow you to define whichever log level you want for this particular component and only the one you define. So all you need is:

log4j.rootLogger=DEBUG, stdout
log4j.logger.jersey-client-async-executor-0=INFO, stdout
log4j.additivity.jersey-client-async-executor-0=false

note you can also set different appenders for each logger you define.