[slf4j-dev] [JIRA] (SLF4J-192) Need ability to shutdown loggers and flush appenders

QOS.CH (JIRA) noreply-jira at qos.ch
Wed Jan 2 15:58:00 CET 2019


    [ https://jira.qos.ch/browse/SLF4J-192?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19388#comment-19388 ] 

Joachim Durchholz commented on SLF4J-192:
-----------------------------------------

What's the point of having a shutdown method in the facade?

Facades are about concentrating the dependency to the backend in one place - or at least no more places than you can count on one hand.
Since shutdown would replace a single call with a single call, it's not saving you anything here. It _is_ giving you a small O(1) benefit in that it defines a standard shutdown point; OTOH I find that logging tends to require some application-specific setup and teardown anyway; there's simply no point in adding such a function.

I think what would be worth thinking about is a single point that handles application setup _and_ shutdown code. Since there are typically dependencies between the two, that would be helpful.
However, that's application-specific. I tend to have a LoggingManagement class that does the setup, and registers a shutdown hook. Plus it deals with those libraries that have non-SLF4J logging, whether because legacy or because the library designer does not want to use SLF4J (I live with both cases).
So, from my perspective, SLF4J isn't even the right place to organize setup and teardown, things are too application-specific.

> Need ability to shutdown loggers and flush appenders
> ----------------------------------------------------
>
>                 Key: SLF4J-192
>                 URL: https://jira.qos.ch/browse/SLF4J-192
>             Project: SLF4J
>          Issue Type: Improvement
>          Components: Core API
>    Affects Versions: 1.6.x
>         Environment: Operating System: All
> Platform: All
>            Reporter: Michael Schall
>            Assignee: SLF4J developers list
>
> There needs to be a way to shutdown logging and flush async appenders so when a process is closing, all log events are written before the process is closed.
> Should ILoggerFactory have a shutdown or stop method?  It could shutdown whatever logging back end I'm using?
> For log4j it would call - org.apache.log4j.LogManager.getLoggerRepository().shutdown();
> For logback it would call - loggerContext.stop()
> Other back ends - ???
> This is required to allow me to not reference logging back ends explicitly in my code to shutdown successfully without losing events.
> Discussion about this is happening on the user list at -
> http://www.qos.ch/pipermail/logback-user/2010-September/001816.html



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)


More information about the slf4j-dev mailing list