By default, the console handler connects to the root log, which is the parent of all other registrars, including yours. Therefore, I see two ways to solve your problem:
If this only affects your specific class, the easiest solution would be to turn off log transfers to the parent logger:
logger.setUseParentHandlers(false);
If you want to change this behavior for your application, you can remove the default console handler from the root logger before adding your own handlers:
Logger globalLogger = Logger.getLogger("global"); Handler[] handlers = globalLogger.getHandlers(); for(Handler handler : handlers) { globalLogger.removeHandler(handler); }
Note. If you want to use the same log handlers in other classes, it is best to move the log configuration to the configuration file in the end.
Péter Török Mar 28 '10 at 14:34 2010-03-28 14:34
source share