aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:Help on Logging messages unusual output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:Help on Logging messages unusual output" Watch "NX:Help on Logging messages unusual output" New topic
Author

NX:Help on Logging messages unusual output

Ray Tan
Greenhorn

Joined: Feb 01, 2004
Posts: 2
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 ]
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Ray,

<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 ]

Regards, George
SCJP, SCJD, SCWCD, SCBCD
Ray Tan
Greenhorn

Joined: Feb 01, 2004
Posts: 2
George, thanks for the answer and your explanation!!!
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi George,
Hope this helps,

Of course it did!
I've nothing to add myself, except:
  • a link to this thread which explains how to use an external logging config file;
  • and that I much appreciate your posts on this forum. Thank you for helping all of us making this forum as helpful as it is. Please keep going!


  • Best regards,
    Phil.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: NX:Help on Logging messages unusual output