• Post Reply Bookmark Topic Watch Topic
  • New Topic

Inner Classes and logging...  RSS feed

James Turner
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...");
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.

[ May 09, 2005: Message edited by: James Turner ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!