tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Pimley <pe...@pimley.com>
Subject Re: Undeploying problem with Tomcat 5.5 and Log4J
Date Wed, 03 Jan 2007 20:56:47 GMT
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?
http://java.sun.com/javase/6/docs/api/java/lang/Object.html#finalize()


It's interesting to note that java.io.OutputStream 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: 
http://logging.apache.org/log4j/docs/api/org/apache/log4j/LogManager.html#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: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message