Forums Register Login
Logger / ShutdownHook
Hi guys. I was having a problem with logging in my shutdown hook and noticed a thread was previously posted in this forum with some advice. The thread is http://www.coderanch.com/t/502088/java/java/Logger-ShutdownHook

I am working on the OCMJD and I created a thread about my particular problem here.

The thread that was in this forum had some advice about how to solve the problem. There seem to be two solutions mentioned:

1) Add the handler back to the logger in the thread that you add using the addShutdownHook method.
2) Use an anonymous logger.

I have tried (1) and it works. But it doesn't seem like a good solution to me. There's no guarantee of when the LogManagers shutdown hook will be executed. So you could add the handler back to the logger in your shutdown thread, only for it to be removed by the LogManagers shutdown before your shutdown completes.

I have tried (2) and it doesn't work - some of my log statements do not get output. But I wonder am I understanding it correctly? I simply used java.util.logging.Logger.getAnonymousLogger() to get the anonymous logger. But maybe something else was meant?

Any ideas folks?
Any ideas guys?

This thread has been viewed 604 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 23, 2018 19:28:05.