• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.util.logging question

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public static void main(String[] args) {
Logger log = Logger.getLogger(Test.class.getName());
ConsoleHandler h = new ConsoleHandler();
h.setFormatter(new SimpleFormatter());
log.addHandler(h);
log.info("Test");
}


Has the following output:


May 23, 2006 4:24:10 PM com.dmotorworks.lib.clie.Test main
INFO: Test
May 23, 2006 4:24:10 PM com.dmotorworks.lib.clie.Test main
INFO: Test


Why is it printing TWICE?
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The default logging configuration already provides a Console Handler. Then you are adding another one. That�s why it is printed twice.

If you do not add another handler it will be printed just once.

The default logging configuration is stored in the jre\lib\logging.properties file.

It is a better idea if you set up your loggin handler from this file or create a new file and set it using the -Djava.util.logging.config.file=myfile command line property, as specified in the default logging configuration file.

I hope this helps!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic