• 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

logger.log......compile error

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
this is a simple logger api example. But it is giving complilation error at logger.log("Level.ALL","Exception..."). Why it is giving like that. Can u pls tell me?
import java.util.logging.*;
public class LoggerTest
{
public static void main(String args[]){

Logger logger = Logger.getLogger("LoggerTest");
try{
Handler handler = new FileHandler("logMessages.log");
handler.setFormatter(new SimpleFormatter() ) ;
logger.addHandler(handler);
//int K=1/0;
}
catch(Exception e)
{
e.printStackTrace();
logger.log("Level.ALL","Exception...");
//logger.log("Level.ALL","Exception...", e);
}
}
}
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Murali Mohan:

logger.log("Level.ALL","Exception...");


According to the API Documentation, the first argument to logger.log is an instance of the class java.util.logger.Level, not a string. Try:
logger.log(Level.ALL,"Exception...");
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Murali
I remember answering the same question by you on this forum. I hope you did see the response and solved the problem as Joe's post also confirms the problem.
OR you are not clear about the explanation?
Regards
Maulin
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic