I have initialized a java.util.logging.Logger bean and now want to add a Handler which I’ve also created a bean for. The trouble is the Logger method is called addHandler instead of something like setHandler.
How can I inject the handler into the logger?
Do I need to wrap Logger in a Spring-friendly bean class?
EDIT
If someone can also tell me how to pass in the logging level (which is a static value) I’d be much obliged.
UPDATE: Changed to use java.util.logging, and show how to set level.
You can use this by having a
FactoryBeanimplementation:Then define your bean in XML like:
Example unit test: