aspose file tools*
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 JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Inner Classes and logging..." Watch "Inner Classes and logging..." New topic
Author

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.
log.info("Server SHUTDOWN: Unexporting all Remote Services...");
DataRMIServer.this.stop();
log.info("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.

James.
[ 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: http://aspose.com/file-tools
 
subject: Inner Classes and logging...