简体   繁体   English

如何记录Spring的SimpleMappingExceptionResolver的异常堆栈跟踪

[英]How to log exception stacktrace for Spring's SimpleMappingExceptionResolver

I'm working on a project where the exception handling was created by someone else who is no longer here to help. 我正在开发一个项目,其中异常处理是由不再在这里提供帮助的其他人创建的。

They've created the following bean which catches all uncaught exceptions and forwards to a JSP View. 他们创建了以下bean,它捕获所有未捕获的异常并转发到JSP View。

<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
  <property name="exceptionMappings">
    <map>
      <entry key="java.lang.Exception" value="error"/>
    </map>
  </property>
  <property name="defaultErrorView" value="error" />
</bean>

It works fine, but what if I want to get a hold of the exception thrown and report it in our logs? 它工作正常,但是如果我想获得抛出的异常并在我们的日志中报告它会怎么样? How do I forward this to a Java class instead of a View? 如何将其转发到Java类而不是View?

Set the properties for warnLogCategory . 设置warnLogCategory的属性。 See the class Javadoc . 请参阅Javadoc类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM