qos-ch / slf4j

Simple Logging Facade for Java
http://www.slf4j.org
MIT License
2.32k stars 980 forks source link

[Feature] 'Strict' startup mode that fails if no or multiple bindings are configured #418

Open stevenschlansker opened 2 months ago

stevenschlansker commented 2 months ago

Hi, we maintain a medium sized Maven project that uses slf4j in all modules. From time to time, we find that committers have inadvertently broken the log setup in some random module - slf4j-simple was pulled in via some transitive test dependency that was removed, or you add a new dependency and now logback comes in too. If you don't watch your test output closely, the SLF4J Warning messages are not found until a Logging Architect comes by and realizes the problem.

Suggested resolution: add a slf4j.strict=true flag that turns related warnings (no providers, multiple providers) into an error (thrown exception to fail initialization) rather than a warning. We can then set this on our build and eagerly fail if any problems are introduced.

I'd be happy to write up a PR if this feature would be accepted. What do you think?