"No Appenders found for logger" and "please configure log4j properly"

Source: Internet
Author: User


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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.