• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

NX:Help on Logging messages unusual output

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ray Tan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
George, thanks for the answer and your explanation!!!
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
     
    Hot dog! An advertiser loves us THIS much:
    New web page for Paul's Rocket Mass Heaters movies
    https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
    reply
      Bookmark Topic Watch Topic
    • New Topic