0
votes
import org.apache.log4j.*;

public class Log {

   public static void main(String[] args) {
       Logger log = Logger.getLogger(Log.class);
       PropertyConfigurator.configure("log.properties");
       log.debug("Hello this is a debug message");
       log.info("Hello this is an info message");
   }

}

Error is :- log4j:WARN No appenders could be found for logger (log.Log). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

1
What does your log.properties look like? I get no warnings testing with org.apache.log4j.ConsoleAppendervsnyc

1 Answers

0
votes

This error usually means that it cannot find log4j.properties on your classpath. Even though you are trying to instantiate your own Configurator, log4j will look for the properties file as part of class loading.