Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 371
Corey Avatar asked Nov 23 '10 00:11

Corey


1 Answers

Set the properties for warnLogCategory. See the class Javadoc.

like image 91
matt b Avatar answered Oct 11 '22 03:10

matt b