In groovy
grails
project, I want to externalized log4j.properties
file and I want to make generic relative path to make it work in Linux
and Windows
.
To externalize, I have removed log4j = { ... }
code from grails-app/conf/Config.groovy
And updated the file grails-app/conf/spring/resources.groovy
with the following code.
beans = {
log4jConfigurer(org.springframework.beans.factory.config.MethodInvokingFactoryBean) {
targetClass = "org.springframework.util.Log4jConfigurer"
targetMethod = "initLogging"
arguments = ["./log4j.properties"]
}
}
The log4j.properties
file is in root directory of tomcat
, where webapps, conf,
etc folders exists.
/tomcat/log4j.properties
The above code works on Windows
but not in linux
machine.
I have tried the following:
Setting the following:
arguments = ["${System.properties['catalina.home']}/log4j.properties"]
Also I have tried setting a value
grails-app/conf/Config.groovy
asgrailsApplication.config.log4j_path = "${System.properties['catalina.home']}/log4j.properties"
And tried using it in grails-app/conf/spring/resources.groovy
file as:
arguments = [grailsApplication.config.log4j_path]
but non worked.
Can someone tell me how can I set path so that it can work in both Windows
and Linux
.
Any help is appreciated.