Use*_*111 8 grails tomcat log4j grails-2.1
在groovy
grails
项目中,我想要外化log4j.properties
文件,我想制作通用的相对路径,使其工作在Linux
和Windows
.
要外部化,我已从中删除log4j = { ... }
代码grails-app/conf/Config.groovy
并grails-app/conf/spring/resources.groovy
使用以下代码更新文件.
beans = {
log4jConfigurer(org.springframework.beans.factory.config.MethodInvokingFactoryBean) {
targetClass = "org.springframework.util.Log4jConfigurer"
targetMethod = "initLogging"
arguments = ["./log4j.properties"]
}
}
Run Code Online (Sandbox Code Playgroud)
该log4j.properties
文件位于根目录中tomcat
,其中webapps, conf,
存在etc文件夹.
/tomcat/log4j.properties
上面的代码可以工作Windows
但不能在linux
机器上工作.
我尝试过以下方法:
设置以下内容:
arguments = ["${System.properties['catalina.home']}/log4j.properties"]
Run Code Online (Sandbox Code Playgroud)此外,我已经尝试设置的值grails-app/conf/Config.groovy
作为
grailsApplication.config.log4j_path = "${System.properties['catalina.home']}/log4j.properties"
Run Code Online (Sandbox Code Playgroud)并尝试在grails-app/conf/spring/resources.groovy
文件中使用它:
arguments = [grailsApplication.config.log4j_path]
Run Code Online (Sandbox Code Playgroud)
但没有工作.
谁能告诉我怎么可以设置路径,以便它可以在工作,都Windows
和Linux
.
任何帮助表示赞赏.
归档时间: |
|
查看次数: |
396 次 |
最近记录: |