boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 179 forks source link

Silence slf4 warnings #676

Closed Deraen closed 6 years ago

Deraen commented 6 years ago

New pomegranate uses new maven-resolver (aether) which uses slf4j-api for logging:

Downloading https://github.com/boot-clj/boot/releases/download/2.8.0-SNAPSHOT/boot.jar...
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.

This means that when it tries to log, it will check if classpath contains any logger implementations. We can't safely add new implementations as it is probably that users do that themselves, and having multiple loggers also causes warning.

Though Maven itself seems to include logger: http://maven.apache.org/ref/3.2.2/maven-embedder/logging.html Might be worth to investigate more on how they prevent warnings.


Some notes from Slack:

Maybe we'll need code to check project deps and only add logger if there isn't one

Or maybe slf4j-api has some method to check if logger is available... and then we can inject logger... if we can do that before it prints the warning, it would probably be most robust solution

https://github.com/qos-ch/slf4j/blob/master/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java#L149

If we can manage to run code before Maven-resolver classes are loaded, we can use java.util.ServiceLoader.load to check for SLF4JServiceProvider and if none is found, add nop/simple logger to classpath

mynomoto commented 6 years ago

Adding slf4j-nop to a project dependencies do not silence the warning, maybe this is running on a pod and we can add it there?

alandipert commented 6 years ago

Fixed by 7709941bcef20de55b940ec18885677df33b7557

I think it's OK to add the slf4j-nop jar to the worker pod because its deps don't interfere with user deps (worker pod classpath is totally isolated)