1.错误
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
log4j:WARN No appenders could be found for logger (freemarker.cache).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Spring 使用了Log4j 这个开源框架来输出信息,要解决这个问题非常简单,建立Log4j 的配置文件即可。在src 目录下创建配置文件,选择菜单File > New > File,文件名输入log4j.properties,文件内容如下所示:【只有加入了这个文件后才能看到Spring 后台完整的出错信息。在开发Spring 整合应用时,经常有人遇到出现404 错误但是却看不到任何出错信息的情况,这时你就需要检查一下这个文件是不是存在。】
log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
或者通过xml文件进行配置
<?xml version="1.0" encoding="GB2312" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="org.zblog.all" class="org.apache.log4j.RollingFileAppender">
<!-- 设置通道ID:org.zblog.all和输出方式:org.apache.log4j.RollingFileAppender -->
<param name="File" value="E:/study/log4j/all.output.log" /> <!-- 设置File参数:日志输出文件名 -->
<param name="Append" value="false" /> <!-- 设置是否在重新启动服务时,在原有日志的基础添加新日志 -->
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%p (%c:%L)- %m%n" /> <!-- 设置输出文件项目和格式 -->
</layout>
</appender>
<appender name="org.zblog.zcw" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="E:/study/log4j/zhuwei.output.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="10240" /> <!-- 设置文件大小 -->
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%p (%c:%L)- %m%n" />
</layout>
</appender>
<logger name="zcw.log"> <!-- 设置域名限制,即zcw.log域及以下的日志均输出到下面对应的通道中 -->
<level value="debug" /> <!-- 设置级别 -->
<appender-ref ref="org.zblog.zcw" /> <!-- 与前面的通道id相对应 -->
</logger>
<root> <!-- 设置接收所有输出的通道 -->
<appender-ref ref="org.zblog.all" /> <!-- 与前面的通道id相对应 -->
</root>
</log4j:configuration>
2.错误
[mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
解决方法:查看tomcat–logs之后发现有错误:org/apache/commons/logging/LogFactory
需要在项目中导入commons-logging-1.2.jar
3.错误
Exception occurred during processing request: null 的错误原因以及解决办法
- 配置applicationContext.xml,注入属性值
- 对于Spring和Struts2整合的项目,struts.xml中的class属性要对应applicationContext.xml中注册的id值