[slf4j-user] Fail Silently on NOP implementation

Phillip Lord phillip.lord at russet.org.uk
Wed Apr 27 08:00:22 UTC 2016



The currently implementation of SLF4J prints a message on usage of the
NOP implementation. This is not very friendly at all, as it means that
if any dependency of my project includes a a dependency on SLF4J, I
suddenly get an error message whether I wish it or not.

It seems poor to me that I should have to add a dependency to slf4j-nop
in my project -- I now have to check everytime I update my dependencies
to see whether this is still necessary, so it's an ongoing cost, in
addition to the initial cost of finding out what this error message is
about in the first place.

I would like to suggest that this message be suppressed unless
explicitly asked for; users of slf4j could them choose to be warned when
they wanted. They could also ask for a fail early implementation as was
requested earlier on this mailing list.

http://mailman.qos.ch/pipermail/slf4j-user/2015-September/001478.html

This could be implemented in a number of ways -- you could make a
slf4j-api-with-noisy dependency, you could look for an environment
variable, or a system property. Users who need the warning would get it,
and end-users who are not using slf4j explicitly would be untroubled by
its presence,


Alternatively, I'd suggest updating this advice:


Embedded components such as libraries or frameworks should not declare a
dependency on any SLF4J binding but only depend on slf4j-api. When a
library declares a compile-time dependency on a SLF4J binding, it
imposes that binding on the end-user, thus negating SLF4J's purpose.

to include

However, we would suggest that libraries and frameworks including a
runtime dependency on slf4j-nop; this can be excluded by end-users
should they wish to replace it with another binding at runtime. 

Thanks!

Phil




More information about the slf4j-user mailing list