m-m-m / util

Mature Modular Meta-Framework
http://m-m-m.sourceforge.net
Apache License 2.0
10 stars 5 forks source link

CLI: Prevent mixture of logging and CLI output #194

Open hohwille opened 8 years ago

hohwille commented 8 years ago

By default CLI (from AbstractMain) should somehow configure the logging such that is silent and does not interfere with the CLI program output. As advanced feature an option or system property should allow to configure the logging to use a specific config file so log messages are printed on console or written to log file. However CLI users do not want to see the ugly 3 lines of SLF4J that no logger binding exists nor want to see the error messasges such as that javax.validation may not be on their classpath, etc. by default.

hohwille commented 8 years ago
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.

It seems we are hitting a limitation of slf4j here: http://www.slf4j.org/codes.html#StaticLoggerBinder

For a CLI program no end user want to see this 3 lines from slf4j mixed in the CLI output if no logger binding is found on the classpath. Therefore slf4j should offer a way to suppress this warning e.g. via a system property.

hohwille commented 8 years ago

If on the other hand we would ship CLI with logback as dependency (or even slf4j-nop what is IMHO both wrong) then we would also need to ship a logback config that prevents any logoutput by default. This would again interfere with projects that just have our lib as dependency for other reasons. It seems that we have a specific use-case that slf4j team probably never thought about...

hohwille commented 8 years ago

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

hohwille commented 7 years ago

https://github.com/qos-ch/slf4j/pull/157

Unfortunately no reaction.

hohwille commented 7 years ago

slf4j does not seem to care about its PRs. I also posted on the mailing list and others have the same problem and their PRs are not commented since over one year. Hence, I am removing the milestone to prevent blocking other issues being solved for the release.