Followers

Saturday, 31 December 2016

Groovy Grails: how to set path of log4j.properties that works in Windows and Linux

Source: stackoverflow.com --- Friday, December 30, 2016
In my 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 as grailsApplication.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. ...



from Windows http://ift.tt/2izMqC9

No comments:

Post a Comment