[logback-user] log files locked after application undeploy

Anton Tagunov anton.tagunov at umail.ru
Tue Jun 3 17:08:53 CEST 2008

Hello Syvalta,

Please notice: this is an advice from user not from logback developers.

am I right that slf4j and logback jars 
* are provided by the web application itself?
* not provided as shared jars by the Servlet container?

in this particular case you can write a ServletContextListener
that will do a very simple thing in contextDestroyed():

public void contextDestroyed(ServletContextEvent servletContextEvent) {

you will also need to register this context listener in web.xml

HOWEVER please note that the setup you're using is somewhat fragile.

If your applicaiton is deployed within a web container that
* does provide logback.jar in classloader shared between web applications
* the classloader used by this servlet container to load your web
  application works in normal parent first order
then you may have issues.

The issues that may happen inlude logback being configured by web-container wide
logback.xml, not by logback.xml provided within your application.
Another possible issue is that the ServletContextListener suggested above
will close logging not for your application only but for other applications also.

The suggested logback setup in a servlet container is described in logback manual
It is suggested to perform this setup in full including JNDI parameter configuration.

If you would like to have more details on why such complex setup is needed
you can find them here

These article discuss other logging libraries but the problem being solved is essentially the same.

with best regards,
Anton Tagunov

On Tue, 3 Jun 2008 02:21:56 -0700 (PDT)
 Syvalta <syvalta at yahoo.com> wrote:
>I have a minor problem with logback (version 0.99). When I undeploy my web
>application the log files are still locked and they remain locked (under
>How is this supposed to work? Is this expected behavior, or does that mean I
>have a resource leak in my application? I see appenders do have stop method,
>but I didn't find any overall shutdown method in Logback. How is log file
>closing supposed to work?
>I have logback.xml in my classpath and I'm not doing any explicit
>initialization. I use RollingFileAppender with TimeBasedRollingPolicy.

More information about the Logback-user mailing list