This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Logger / ShutdownHook Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Logger / ShutdownHook" Watch "Logger / ShutdownHook" New topic
Author

Logger / ShutdownHook

Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

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?


SCJP (1.4 | 5.0), OCJP (6.0), OCMJD
Sean Keane
Ranch Hand

Joined: Nov 03, 2010
Posts: 581

Any ideas guys?
 
Don't get me started about those stupid light bulbs.
 
subject: Logger / ShutdownHook
 
Similar Threads
Logging in a Shutdown Hook
Problem(?) in Andrew's Denny Dvd setDatabaseLocked() method
Inner Classes and logging...
Logging API/Lock Files
Detect windows shutdown