Java – spring MVC does not record all exceptions

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
分享
二维码
< <上一篇
下一篇>>