在使用struts开发的过程中,有的错误在页面上能显示但是不如在控制台显示的清楚,我们需要配一下让原本在浏览器页面上显示的错误也能现实在控制台中。
1、log4j.properties 加入
2、在strutts.xml配置文件中配置exception拦截器的几个属性
1、log4j.properties 加入
com.bjsxt是个包名 意思是:记录这个包(包含子包)下程序运行所产生的日志信息
log4j.logger.com.bjsxt=debug2、在strutts.xml配置文件中配置exception拦截器的几个属性
<interceptor-stack name="myInterceptorStack">
<interceptor-ref name="exception">
<!--启用日志记录 -->
<param name="logEnabled">true</param>
<!--确认日志记录的程序所在的包名 -->
<param name="logCategory">com.bjsxt</param>
</interceptor-ref>
<interceptor-ref name="pagerInterceptor"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
本文详细介绍了如何在使用Struts框架开发过程中,通过配置log4j.properties文件和修改strutts.xml配置文件,实现将页面上显示的错误信息同步记录到控制台,提升错误诊断效率。
1637

被折叠的 条评论
为什么被折叠?



