Click to See Complete Forum and Search --> : Deactivate Console Handler in java.util.logging


StarShaper
May 8th, 2008, 12:51 PM
Hi,

I would like to deactivate the Console Handler for all logging events. I'm writing all log events with a File Handler directly to a file, but I don't know how to deactivate the Console Handler.

Any hints? :wave:

dlorde
May 8th, 2008, 01:27 PM
Hints? RTFM :p

The JavaDoc for the Handler class says "A Handler can be disabled by doing a setLevel(Level.OFF) and can be re-enabled by doing a setLevel with an appropriate level.".

Experience is a poor teacher: it gives its tests before it teaches its lessons...
Anon.

Martin O
May 8th, 2008, 01:35 PM
I think I've had this problem & used the following to fix it:

private static final Logger m_logger = Logger.getLogger("com.mycompany.myapp.trace");
...
m_logger.setUseParentHandlers(false);

If I remember correctly, the 'parent handlers' were doing the console logging that I wanted to turn off & thats how I handled it.

StarShaper
May 8th, 2008, 03:01 PM
Sorry, my fault. Just was to lazy to search the manual, rather asking the experts. ;)

Thanks dlorde & Martin O!

Both solutions work. :thumb: