I am performing a simple test with logging. I have the following code which was basically a cut and paste job from Sun's Logging Overview page LINK It outputs fine. But it outputs the message TWICE (see below) - this is the problem . I searched the API and Sun's Overiew page and cannot find why it would be doing this. Any ideas?
OUTPUT: Feb 1, 2004 2:03:27 PM Test main INFO: doing stuff Feb 1, 2004 2:03:27 PM Test main INFO: doing stuff thanks, rt [ February 01, 2004: Message edited by: Ray Tan ]
<hr></blockquote> Those changes will get rid of the double output, but it's much better to do the following:
You probably have a default console handler set up in one of the logging.properties files. Assuming you don't have a logging.properties file locally, then you should check the one in C:\j2sdk1.4.2_02\jre\lib\logging.properties file (of course you need to replace C:\j2sdk1.4.2_02 with your java home directory) and you'll probably find the following:
So that's where your other console handler was coming from and you were just chaining an additional console handler to the one you already got from the logging.properties file. The best way to do this is probably to use your own local logging.properties file (this way it is configurable without code change), but if you want to continue doing it programmatically (as you were) then the "logger.setUseParentHandlers(false);" should eliminate the default console handler you're picking up from the logging.properties file. Hope this helps, George [ February 01, 2004: Message edited by: George Marinkovich ]
SCJP, SCJD, SCWCD, SCBCD
Joined: Feb 01, 2004
George, thanks for the answer and your explanation!!!