在Grails Log4j DSL配置中使用Log4j过滤器 [英] Log4j filter in Grails Log4j DSL configuration
本文介绍了在Grails Log4j DSL配置中使用Log4j过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在 Grails log4j DSL 配置?我需要在我的Grails log4j配置中定义类似这样的内容:
Is there a way to specify a log4j filter in Grails log4j DSL configuration? I need to define something like this in my Grails log4j config:
<filter class="org.apache.log4j.filter.ExpressionFilter">
<param name="expression" value="EXCEPTION ~= com.company.BackendNotAvailableException" />
<param name="acceptOnMatch" value="false"/>
</filter>
我使用Grails 1.3.7。
I use Grails 1.3.7.
推荐答案
我已经为Bootstrap.groovy添加了一个简短的init代码来解决这个问题。
I have worked around this issue by adding a short init code to Bootstrap.groovy
Logger.rootLogger.allAppenders.each { appender ->
ExpressionFilter filter = new ExpressionFilter()
filter.expression = "EXCEPTION ~= org.springframework.security.authentication.*"
filter.acceptOnMatch = false
filter.activateOptions()
appender.addFilter(filter)
}
这篇关于在Grails Log4j DSL配置中使用Log4j过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文