Log4j:warn no appenders could is found for logger. Console cannot output SQL

Source: Internet
Author: User

The following error occurred while running the Java Project project several days ago:

    

1. First see if the file name is: Log4j.properties or log4j.xml.

2. After confirming that the file location is correct, Java project needs to place the file in: Project/src/or project/Custom folder/. Put it in the top-level directory,

Web Projiect need to put files in the \web-inf\classes folder.

3. If there is no error, it is only to see if the file itself is wrong.

The Java project configuration is as follows:

# Global Logging Configuration
#\u5728\u5f00\u53d1\u73af\u5883\u4e0b\u65e5\u5fd7\u7ea7\u522b\u8981\u8bbe\u7f6e\u6210debug\uff0c\u751f\u4ea7\ U73af\u5883\u8bbe\u7f6e\u6210info\u6216error
Log4j.rootlogger=debug, stdout
# Console Output ...
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
log4j.appender.stdout.layout.conversionpattern=%5p [%t]-%m%n

The Web project is configured as follows:

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/config/log4j.properties</param-value>
</context-param>

······

<!--definition log4j listener--
<listener>
<listener-class>
Org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>

This article is to see a number of Bo Friends of the blog summary of the solution, if there are other solutions, hope to share a bit! After solving this problem, SQL can also output from the console:

Reference post: http://blog.sina.com.cn/s/blog_5f7d1a610100ebph.html

http://wukunlsy.iteye.com/blog/772616 (Ben Boven helped me solve my problem)

Log4j:warn no appenders could is found for logger. Console cannot output SQL

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.