`

如何让log4j日志信息不止在页面显示在控制台也能打印

阅读更多
在使用struts开发的过程中,有的错误在页面上能显示但是不如在控制台显示的清楚,我们需要配一下让原本在浏览器页面上显示的错误也能现实在控制台中。
1、log4j.properties 加入
com.bjsxt是个包名 意思是:记录这个包(包含子包)下程序运行所产生的日志信息
log4j.logger.com.bjsxt=debug


2、在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"/>



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics