Why does I see a warning about "No Appenders found for logger" and "please configure log4j properly"?
This occurs when the default configuration files Log4j.properties The and log4j.xml can not is found and the application performs no explicit configuration.
Log4j uses thread.getcontextclassloader (). GetResource () to locate the default configuration files And does not directly check the file system. Knowing the appropriate location to place log4j.properties or log4j.xml requires understanding the search strategy of the class loader in use. LOG4J does not provide a default configuration since output to the console or to the file system could be prohibited in some Environments.
Also see faq:why can ' t log4j find my properties in a EE or WAR application?.
Why can ' t log4j find my properties file in a EE or WAR application? The
the short answer:the log4j classes and the properties file is not within the scope of the same classloader.
The long answer (and what does about it): EE or Servlet containers utilize Java ' s class loading system. Sun changed the classloading works with the release of Java 2. In Java 2, Classloaders is arranged in a hierarchial parent-child relationship. When a child classloader needs to find a class or a resource, it first delegates the request to the parent.
log4j only uses the default class.forname () mechanism for loading classes. Resources are handled similarly. See the documentation for Java.lang.ClassLoader for more details.
So, if you ' re has problems, try loading the class or resource yourself. If you can ' t find it, neither'll log4j. ;)
http://logging.apache.org/log4j/1.2/faq.html#a3.5
"No Appenders found for logger" and "please configure log4j properly"