tags:

views:

425

answers:

3

Hi I'm using log4j api for logging purpose. When I use the following code to append to the appender, it's showing "addAppender() is undefined for the type Logger" error

FileAppender myAppender = new FileAppender(new PatternLayout(),"output.log");
Logger.getLogger(ConfigFileReader.class.getName()).addAppender(myAppender);

Can anyone tell me what should I do to debug this error?

+6  A: 

Are you sure that you are importing the correct Logger class? A common error is to import java.util.Logger instead of the Logger from the log4j package.

Martin OConnor
A: 

Hi, You are correct.. I have made a common error as u said.. Thanks a lot.....

raja
why not mark my answer as correct?
Martin OConnor
A: 

Mark the guy's answer as correct, dude.

Mihai Danila