`
hanyou
  • 浏览: 21887 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

log4j的配置在Seam例子中不起作用的原因

    博客分类:
  • SEAM
阅读更多
研究了一个Seam的log功能,书上说使用@Logger的注解就可以方便使用log.info,log.debug,而不需要再写输出级别的判断,我在booking例子中的AuthenticatorAction增加log.info和log.debug的输出,然后把log4j.xml拷贝到classes目录下,发现不管怎么设置log4j.xml的输出级别,只能输出log.info的内容,实验了多次也没有解决,最后检查lib下面jar中是否存在另外的log4j的配置,才发现在lib下没有log4j的jar包,如果没有这个jar包,seam默认使用sun的log输出,将此jar拷贝到lib目录下,问题解决,另外想从log4j的目录下输出indentity组件的用户id,以前是我自己写一个filter来解决,现在seam已经为大家写好了。

这个过滤器将被验证的用户名添加到log4j映射诊断上下文中,以便如果喜欢,可能通过在模式中添加%X{username},使它能够被包含在格式化过的日志输出中。

默认情况下,记录过虑器会处理所有请求,但是这一行为可以通过在 components.xml 中添加 <web:logging-filter> 项来进行调整,如下面的例子所示:

<components xmlns="http://jboss.com/products/seam/components"
            xmlns:web="http://jboss.com/products/seam/web">
    <web:logging-filter url-pattern="*.seam"/>
</components>
url-pattern — Used to specify which requests the filter is active for. The default is all requests. url-pattern —用来指定该过滤器是为哪些请求而激活的。默认是所有请求。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics