[英]Grails with external log4j with name “${appname}.log”, it not work
1.Grails version 2.5.1 1.Grails版本2.5.1
i used Grails external log4j like this in env: 我在环境中使用Grails外部log4j像这样:
grails.config.locations = ["file:${basedir}/grails-app/config/log4j.groovy"]
and log4j.groovy like this 和log4j.groovy像这样
log4j = {
appenders {
appender new org.apache.log4j.DailyRollingFileAppender(name:"dailyAppender",
layout:pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss,SSS} %l %c{3} %m%n'),fileName:"D:\\error-logs\\b2-error.log",datePattern:"'.'yyyy-MM-dd")
}
console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
error 'org.codehaus.groovy.grails.web.servlet',
'org.codehaus.groovy.grails.web.pages',
'org.codehaus.groovy.grails.web.sitemesh',
'org.codehaus.groovy.grails.web.mapping.filter',
'org.codehaus.groovy.grails.web.mapping',
'org.codehaus.groovy.grails.commons',
'org.codehaus.groovy.grails.plugins',
'org.codehaus.groovy.grails.orm.hibernate',
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
debug "grails.plugin.mail",
"gsuk.sms",
'grails.app.jobs',
"gsuk.service"
}
well,it error when the “=” in log4j.groovy 好吧,当log4j.groovy中的“ =”时出现错误
i don`t know why and how to make it work 我不知道为什么以及如何使其工作
by the way ,if i use it in config.groovy ,everything is ok ... 顺便说一句,如果我在config.groovy中使用它,一切都很好...
I have something similar in my environment and it's working just fine. 我的环境中有类似的东西,并且工作正常。 The difference may be that I have a log4j section in both my internal and external Config.groovy files. 不同之处可能是我的内部和外部Config.groovy文件中都有一个log4j部分。 In my \\grails-app\\conf\\Config.groovy
file I have: 在我的\\grails-app\\conf\\Config.groovy
文件中,我有:
grails.config.locations = ["file:path\to\external-config.groovy"]
...
log4j.main = {...}
In my external-config.groovy I have: 在我的external-config.groovy中,我有:
log4j.external = {...}
This allows me to have both an base log4j definition used in my application at all times and then an external one I can append to the internal one. 这使我既可以在应用程序中始终使用基本的log4j定义,又可以在内部添加一个外部定义。 You just have to name them something differently, doesn't have to be .main
or .external
, it could be .foo
and .bar
. 您只需.main
它们命名不同的名称,不必是.main
或.external
,也可以是.foo
和.bar
。
${appName}
does not work in external config files, at least in Grails2. ${appName}
在外部配置文件中不起作用,至少在Grails2中不起作用。 Use grails.util.Metadata.current.getApplicationName()
(in or out of ${}
). 使用grails.util.Metadata.current.getApplicationName()
(在${}
内或之外)。 See: access to application properties (${appName}) in external configuration 请参阅: 在外部配置中访问应用程序属性($ {appName})
Although I don't see appName
anywhere in your example log4j code. 尽管在示例log4j代码中的任何地方都看不到appName
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.