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

QOS.CH (JIRA) noreply-jira at qos.ch
Sun Dec 23 20:17:00 CET 2018


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

Andrea Santi commented on SLF4J-192:
------------------------------------

8 years? Really? After 8 years we are still debating about this?

 

There are some resources that need to be cleaned when the application close. There are some appenders that need to shutdown resources gracefully when an application is closed. E.g. the logfaces appender creates background threads to send logs to an external log monitoring system and without a proper shutdown hook in SLF4J api they are destined to stay there in background and create a huge leak.

Since I'm using log4j 2 as the underlying logging library today I'm forced to do the following

*LogManager.shutdown();* 

But this is so wrong! It entirely blows up the idea of the *FACADE*. If we need to directly call a method of the *REAL* implementation of the logging library then this is not a FACADE anymore.

I totally agree with Alexander and Sean. " *If I am building a code dependency on the underlying logger, why even use SLF4J?* 

What can be done to make things progress? Open another ticket (version 1.6 is no longer "actual")?

Any feedback woudl be really appreciated.

> 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