Problem in addAppender () method in Log4j API

Hi I am using log4j api for logging purposes. When I use the following code to add to my application, it shows that "addAppender () is undefined for a Logger error like

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?

+1


source to share


1 answer


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



+10


source







All Articles