I. log4j.properties
1. Log4j.properties is not readable in the src/main/rescours directory of the spring project.
After the test found that the Log4j.properties file needs to be placed in the src/main/webapp/web-inf directory,
2. Web. XML configuration
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/web-inf/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
3. log file path in Log4j.properties
${webapp.root}/....
4. Code
private static final Log log= logfactorygetLog ("logname");
Two. Log4j.xml
1. Log4j.xml can be read in the src/main/rescours directory of the spring project.
2. Web. XML configuration
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<context-param>
<param-name>rootLevel</param-name>
<param-value>DEBUG</param-value>
</context-param>
<context-param>
<param-name>loggingLevel</param-name>
<param-value>INFO</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
3. log file path in Log4j.properties
${webapp.root}/....
4. Code
Import Org.slf4j.Logger;
Import Org.slf4j.LoggerFactory;
private static final Logger log= loggerfactorygetLogger ("logname");
Spring Log4j.properties does not have a log problem