[slf4j-user] Fail Silently on NOP implementation

Phillip Lord phillip.lord at russet.org.uk
Fri Apr 29 07:54:52 UTC 2016


Ceki, thanks for taking the time to reply (again!)


Ceki Gulcu <ceki at qos.ch> writes:

As a new user to SLF4J, would
>> you really enjoy learning how to use dependency excludes as a
>> debugging tool during your “why won’t my logging show up”
>> journey rather than having a clear error message that informs you that
>> you’re doing it wrong, and pointing you towards the URL with more
>> info? This complicates logging, and the debugging thereof, without a
>> clear gain.
>
> Yes. Well put.

There is a clear gain. Including a dependency on slf4j directly or
indirectly causes an immediate error message to standard err which, I
suspect, causes confusion to indirect users of slf4j.

I do understand why it does this -- any other library that did this I
would say "well use a logger and turn it off-by-default", which is
clearly not an option for you. At the same token, with its current
behaviour, I would not choose to use slf4j myself.


> Yes, having two artifacts seems reasonable to me. However, it may be asking
> too much of someone two create two artifacts just to tame logging.

I think that it is too much.

> In any case, SLF4J implicitly assumes that there is a clear
> distinction between code packaged as a library and code packaged as an
> application.


The only reason that this distinction is an issue is because SLF4J
prints to stderr by default. Would you be willing to consider providing
a mechanism to pacify this error message? Then, downstream library
authors could choose to do this, without having to include the nop
binding and face being asked to "mend their ways".

This could be achieved with very little code.

If you are not prepared to do this then, of course, that is entirely
your decision, and I can respect the reasons. I will just include the
slf4-nop dependency and move on!

Phil


More information about the slf4j-user mailing list