• Post Reply Bookmark Topic Watch Topic
  • New Topic

logger.log......compile error  RSS feed

 
Murali Mohan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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);
}
}
}
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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...");
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!