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