I'm using java.util.logging to implement logging in my EJBs.
I want all loggers (one for each class) to write to a single file. To do this, every logger must share a single Handler (an instance of FileHandler).
So, I've extended the Logger class such that a call to Logger.getLogger() attempts to retrieve a handler from JNDI; if the lookup fails, a new handler is created and bound.
Obviously this is almost a singleton, but not quite because there's no synchronization.
Is this solution crap? Any patterns/ideas/comments/anything?
At first I thought the JNDI lookup would be too time-consuming, but then I realized the lookup would only occur the first time the logger is used. So that shouldn't be a significant issue.
Sounds like you might need synchronization, however.