In your Spring servlet.xml, add a HandlerExceptionResolver.
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <prop key="java.lang.Exception">/error/default</prop> </props> </property> <property name="defaultErrorView" value="/error/default" /> <property name="warnLogCategory" value="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" /> </bean>
“/error/default” is the URL it will go to that will display an error message to the user. warnLogCategory is the logger category. Exceptions will be logged under the warning level and not the error level. The category value can be anything. Here we just set it to the full name of SimpleMappingExceptionResolver.
Spring HandlerExceptionResolver won’t handle errors in the view, so capture these using web.xml
<error-page> <exception-type>java.lang.Exception</exception-type> <location>/error/default</location> </error-page>
I tried with property “warnLogCategory” for exception logging..
No exception being logged in the log file.. Do we need to do specific configuration in log4u.properties file ?
please suggest.
Hi, your right, log4j configuration is needed
see the sample app below, it has example for using properties and xml log4j configuration.
https://www.box.com/s/p2qb19bjv6nv1z06fvsy
wrong link
use this https://www.box.com/s/l8b8i59q5sv3tvc25gl3