Grails 1.1.1 log4j DSL 对 PatternLayout 配置抛出 MissingMethodException
我已将 Grails 1.0.3 应用程序升级到 Grails 1.1.1。我已升级 Config.groovy 中的 log4j 配置以符合 新 DSL。但是,在使用 PatternLayout 定义 ConsoleAppender 后,应用程序将不会启动,而是抛出 MissingMethodException 并显示以下消息:(
groovy.lang.MissingMethodException: No signature of method: \
groovy.util.ConfigSlurper$_parse_closure5.pattern() is applicable \
for argument types: (java.util.LinkedHashMap) \
values: [[conversionPattern:%d{ISO8601} [%10.10t] [%18.18c] [%5p] - %m%n]]
为了便于阅读,我将上述消息分成多行)。
我的配置是:
environments {
development {
log4j {
appenders {
console name: 'myAppender',
layout: pattern(conversionPattern: '%d{ISO8601} [%10.10t] [%18.18c] [%5p] - %m%n')
...
}
root {
error 'myAppender'
additivity = true
}
error 'org.codehaus.groovy.grails.plugins',
'org.codehaus.groovy.grails.orm.hibernate',
...
}
...
}
我尝试更改模式,为 console() 函数添加括号,但没有成功。 是什么原因导致此异常?
I've upgraded a Grails 1.0.3 app to Grails 1.1.1. I've upgraded the log4j configuration in Config.groovy to conform to the new DSL. However, after defining a ConsoleAppender with a PatternLayout, the application won't start, and instead throws a MissingMethodException with the message:
groovy.lang.MissingMethodException: No signature of method: \
groovy.util.ConfigSlurper$_parse_closure5.pattern() is applicable \
for argument types: (java.util.LinkedHashMap) \
values: [[conversionPattern:%d{ISO8601} [%10.10t] [%18.18c] [%5p] - %m%n]]
(I broke the above message into multiple lines for readability).
My configuration is:
environments {
development {
log4j {
appenders {
console name: 'myAppender',
layout: pattern(conversionPattern: '%d{ISO8601} [%10.10t] [%18.18c] [%5p] - %m%n')
...
}
root {
error 'myAppender'
additivity = true
}
error 'org.codehaus.groovy.grails.plugins',
'org.codehaus.groovy.grails.orm.hibernate',
...
}
...
}
I've tried changing the pattern, adding parentheses for the console() function, but with no success. What's causing this Exception?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明我在配置中错过了一个等号。解决方案是更改:
与文档中的示例相比,一旦您看到它,就会发现它是
非常明显的解决方案,但是当您在 DSL 中的特定闭包/方法中遇到错误时,这些错误并不能明显看出真正的问题问题是。
Turns out I had missed an equals sign in the configuration. The solution was to change:
to
Pretty obvious solution once you see it as compared to the examples in the documentation, but when you're getting errors for specific closures/methods within the DSL, the errors don't make it obvious what the real issue is.