• 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

How to stop logging to console

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using java.util.logging.Logger class to log error messages to a file.
All the error messages are directed to a .log file properly. But, the same error messages are even appearing on a console. I want to avoid this. I appriciate anyone's help on this:

Below is the code:


try
{

logger= Logger.getLogger("org.mirapoint.LogMonitor");
logToFile=new FileHandler("LogMonitor_erros.log");
logToFile.setFormatter(new SimpleFormatter());
logger.setLevel(Level.SEVERE);
logger.addHandler(logToFile);
Properties prop = new Properties();
prop.load(new FileInputStream("monitor.properties"));
}

catch(FileNotFoundException fnf)
{
logger.log(Level.SEVERE," The Exception is :",fnf);
}
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kala!

Just add this line to your code...

logger.setUseParentHandlers(false);

Cheers,

'JCP'
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic