tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Lucia" <>
Subject RE: Undeploying problem with Tomcat 5.5 and Log4J
Date Wed, 03 Jan 2007 21:32:53 GMT
The following works fine for me, and has for years:

public class ApplicationLifecycleListener implements ServletContextListener 
    private final static Log logger =

    public void contextInitialized(ServletContextEvent sce) 
    {"Application context initialized.");

    public void contextDestroyed(ServletContextEvent sce) 
    {"Application context destroyed.");


> -----Original Message-----
> From: Peter Pimley []
> Sent: Wednesday, January 03, 2007 3:57 PM
> To: Tomcat Users List
> Subject: Re: Undeploying problem with Tomcat 5.5 and Log4J
> Caldarale, Charles R wrote:
> > Please don't use finalize() if you can possibly avoid it - it really
> > bogs down the internal workings of the JVM.
> Hello.  I'm new here :)
> I don't think you're even guaranteed that finalize will be called at all
> are you?
> It's interesting to note that objects (and so
> FileOutputStreams and, indirectly, FileWriters) call close within their
> finalize method.  This means that nine times out of ten you can happily
> forget about them without bothering to call close, and eventually either
> they get finalized and closed, or your entire application exits anyway.
> You can get in trouble when the JVM does not exit when you're
> "finished".  Could it be possible that within log4j there's a
> FileOutputStream with your log file open that has not been finalized
> yet?  IIRC, Log4j keeps secret handles to Logger instances in order to
> give you the same Logger on duplicate calls to getLogger().
> If I were in your position I'd have a good look through the log4j
> documentation and try and find ways of explicitly shutting down the
> entire system.
> Maybe this is what you're after:
> shutdown()
> (disclaimer: It's been about a year while since I looked at anything in
> that sort of area!)
> HTH,
> Peter Pimley
> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message