[slf4j-user] Recommendation for library writers: use thiscopy and paste wrapper around SLF4j to avoid default static initialization

Matt Sicker boards at gmail.com
Mon Mar 20 02:15:01 CET 2017


There are four primary backends for logging that I know of (in historical
order of appearance):

* Log4j 1.x
* java.util.logging
* Logback
* Log4j 2.x

On the other hand, there are "frontends" for logging which generally fall
into Commons Logging, SLF4J, and Log4j 2.x. Log4j 1.x presented a bit of a
hybrid approach just like java.util.logging. The frontends will work with
any backend in practice, and any backend can be configured for any
frontend, but in general, you should stick to one backend per application
so that all frontends use the same backend.

On 18 March 2017 at 19:34, Joachim Durchholz <jo at durchholz.org> wrote:

> Am 18.03.2017 um 23:24 schrieb Adam Gent:
>
>> However I do think I have a strong understanding of what SLF4J does
>>
>
> You're talking about a chicken/egg problem where nobody else sees it, and
> your statements didn't match with what I know about the internals so either
> the statements or your understanding are incomplete.
>
> It just feels wrong to make
>> Appenders or whatever logging framework specific code to do that sort
>> of initialization.
>>
>
> Sure, appenders shouldn't be doing anything beyond appending log messages
> to whatever output media they are writing to.
>
> How do you configure your logging framework? We have code that presets
>> System.properties (since sadly system.properties is the universal
>> config) before the logging framework. Do you just hard code it and
>> rely on some external mechanism for collecting logs?
>>
>
> Usually I just use logback and configure it.
> Unless I'm inside a container, where the container has a preinstalled and
> (hopefully) preconfigured logging backend.
>
> > Remember I'm
>
>> dealing with several logging backends.
>>
>
> With SLF4J, you do not need multiple backends.
> I'd be pretty unsurprised if SLF4J even prevented you from doing that.
>
> Maybe we have a terminology difference?
> My definition of "backend" is "any of java.util.logging, log4j, commons
> logging, or similar".
>
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/slf4j-user
>



-- 
Matt Sicker <boards at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20170319/f84d781f/attachment.html>


More information about the slf4j-user mailing list