Java – spring MVC does not record all exceptions
•
Java
I have spring MVC settings to log exceptions using commons, but I find that some runtime exceptions are not logged
This is the bean configuration of the default exception parser provided by spring:
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="java.lang.Exception">error</prop> </props> </property> </bean>
Solution
In order to log most exceptions, I must add the following lines to my configuration:
<property name="warnLogCategory" value="someCategoryStringYouMakeUp" />
So eventually it became the following:
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="warnLogCategory" value="apperror" /> <property name="exceptionMappings"> <props> <prop key="java.lang.Exception">error</prop> </props> </property> </bean>
Warnlogcategory is described in detail here
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码