Meaningless Drivel is fun!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Inner Classes and logging... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Inner Classes and logging..." Watch "Inner Classes and logging..." New topic

Inner Classes and logging...

James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Hi Guys,

I have been having some strange results from my code to do with logging within an inner class...

I have this class:

public class ShutdownHook extends Thread {
public void run() {
try {
// Stop server."Server SHUTDOWN: Unexporting all Remote Services...");
DataRMIServer.this.stop();"Server successfully stopped.");
} catch (BodgittScarperException bse) {
log.warning("Caught " + bse);
log.warning("Cannot stop server: JVM Halting");

and am using it with this line in the constructor of the server class:

// Add shutdown hook.
Runtime.getRuntime().addShutdownHook(new ShutdownHook());

Sometimes the logging prints other times it does not... I suspect that the console is being disconnected from the program before the logging finishes, this happens also to the log file. I am not sure why or how to stop this happening... would anyone know or have any ideas as to how to keep the logging handlers available until the logging is finished.

Thank you for any help.

[ May 09, 2005: Message edited by: James Turner ]

James<br />SCJP 1.4 - 92%<br />SCJD - 93%<br />SCWCD 1.4 - 95%<br />SCBCD 1.3 - 100%<br />SCEA - 92%
I agree. Here's the link:
subject: Inner Classes and logging...
It's not a secret anymore!