问题描述
一个spring mvc项目,异常信息直接输出到页面上,而控制台日志里面却没有打印异常堆栈信息?
如下图:
控制台日志却不打印异常信息
问题出现的环境背景及自己尝试过哪些方法
背景:
spring mvc项目,spring版本4.3.25,日志组件用的是slf4J+logback
尝试过的方法:
1.一开始查阅资料,以为是日志组件的问题,在web.xml文件中配置了 logback.xml的监听器,不起作用
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:META-INF/spring/spring-config.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>manage-web.all.root</param-value>
</context-param>
<!-- Processes application requests -->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:META-INF/spring/springMVC-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
检查一下你的logback日志配置文件,看看error信息有没有输出配置到console.~~~~