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

Joachim Durchholz jo at durchholz.org
Sun Mar 19 01:34:57 CET 2017


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".


More information about the slf4j-user mailing list