[logback-user] Shutting down async appenders, when using logback through slf4j
Mads Bondo Dydensborg
mbd at dbc.dk
Fri Jun 14 10:50:33 CEST 2013
(Moved to list for the benefit of google)
Torsdag 13 juni 2013 17:54:58 skrev Ceki Gülcü:
>
> On 6/13/2013 5:17 PM, Mads Bondo Dydensborg wrote:
> > Thank you!
> >
> > But .. that anchor does not appear to be present in the text?
>
> It takes 30 minutes for changes on the master server to propagate to the
> slaves. Please try again.
Thanks, it is there now.
>
> > Also, can this be done from the config file? Because the app only knows slf4j ... :-/
>
> How can the config file know when to shutdown logback? Only code invoked
> at application redeploy, such as
> ServletContextListener.contextDestroyed(), can shutdown logback.
What do I know - perhaps it was possibly to do some magic there ;-)
I have inserted this code in the contextDestroyed method:
if ( LoggerFactory.getILoggerFactory() instanceof LoggerContext ) {
((LoggerContext) LoggerFactory.getILoggerFactory() ).stop();
}
I guess I was not aware that the getILoggerFactory would return such code. Now I just hope that it is still possibly to use this with Log4j or other slf4j compatible frameworks.
Thanks a lot.
Mads
>
>
>
> > Mvh
> >
> > Mads
> >
> > Torsdag 13 juni 2013 16:42:19 skrev Ceki Gülcü:
> >> You need to shutdown logback when redeploying your app. See
> >>
> >> http://logback.qos.ch/manual/configuration.html#stopContext
> >>
> >> Let us know if this helps,
> >>
> >> On 6/13/2013 1:21 PM, Mads Bondo Dydensborg wrote:
> >>> Hi all
> >>>
> >>> I have a feeling that this is a FAQ, but my google-foo failed me.
> >>>
> >>> We provide an application that uses slf4j. The users configure it, in
> >>> logback.xml, to use, among other things, an async appender.
> >>>
> >>> Tomcat complains about this, when redeploying or shutting down:
> >>>
> >>> SEVERE: The web application [/openformat] appears to have started a
> >>> thread named [AsyncAppender-Worker-Thread-2] but has failed to stop it.
> >>> This is very likely to create a memory leak.
> >>>
> >>> I found this issue/request:
> >>> http://bugzilla.slf4j.org/show_bug.cgi?id=201 (Need ability to shutdown
> >>> loggers and flush appenders), but it does not seem that this request has
> >>> been honored.
> >>>
> >>> So, what is the recommended way to solve this? We would like to not
> >>> hardcode the app to use logback (as it could potentially be used with
> >>> log4j), but there seems to be no way to stop an async appender that the
> >>> users have configured in?
> >>>
> >>> Thanks in advance.
> >>>
> >>> Mads
> >>>
> >>> --
> >>>
> >>> Med venlig hilsen/Regards
> >>>
> >>> Chefarkitekt/Chief Architect cand.scient.dat, Ph.d., Mads Bondo Dydensborg
> >>>
> >>> Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 29 84
> >>> 00 42
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Logback-user mailing list
> >>> Logback-user at qos.ch
> >>> http://mailman.qos.ch/mailman/listinfo/logback-user
> >>>
> >> _______________________________________________
> >> Logback-user mailing list
> >> Logback-user at qos.ch
> >> http://mailman.qos.ch/mailman/listinfo/logback-user
> >>
> >>
> >>
>
>
>
--
Med venlig hilsen/Regards
Chefarkitekt/Chief Architect cand.scient.dat, Ph.d., Mads Bondo Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 29 84 00 42
More information about the Logback-user
mailing list