JENKINS-50970 SLF4J logging not working in Swarm client #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When the Swarm Client starts, the following message gets printed:
Note that this doesn't prevent
java.util.logging
logs from getting printed.Evaluation
Both Swarm and Remoting use
java.util.logging
and import neither SLF4J nor Jakarta Commons Logging (JCL), so I wondered SLF4J was in the picture at all here. I asked myself: should we remove SLF4J? Then I realized that we depend oncommons-httpclient
, which itself depends on JCL:So SLF4J isn't completely useless; we can use it to bridge the log statements made by
commons-httpclient
to thejava.util.logging
stream already used by Swarm and Remoting. But right now SLF4J doesn't have any backend configured, hence the warning.Solution
Add an SLF4J backend. Of the many available choices, it made the most sense to use the
java.util.logging
backend. The vast majority of log statements are already made tojava.util.logging
directly by Swarm and Remoting. This change just adds the log statements made bycommons-httpclient
(through JCL) to this stream.Bonus
Bumped the version of
maven-shade-plugin
while I was here.Testing
Ran the Swarm client with a verbose
java.util.logging
configuration. Ensured that the error had disappeared and that JCL log statements fromcommons-httpclient
were making it into the FINE level logs via SLF4J.