From the Grails documentation and this question:
For general configuration Grails provides two files:
- grails-app/conf/BuildConfig.groovy
- grails-app/conf/Config.groovy
Both of them use Groovy's ConfigSlurper syntax. The first, BuildConfig.groovy, is for settings that are used when running Grails commands, such as compile, doc, etc. The second file, Config.groovy, is for settings that are used when your application is running. This means that Config.groovy is packaged with your application, but BuildConfig.groovy is not.
And here is an extract about the log4j framework:
Grails uses its common configuration mechanism to provide the settings for the underlying Log4j log system, so all you have to do is add a log4j setting to the file grails-app/conf/Config.groovy.
I have a project with these two files: grails-app/conf/BuildConfig.groovy and grails-app/conf/Config.groovy. The project uses the log4j utility, so some settings (including a function) are placed in the Config.groovy file. Now, according to the documentation I quoted, it is the right file, since I want to use the logging utilities for running the application, not compiling it.
What's interesting, these settings are used when I run mvn package on my project - the function inside the log4j settings is executed.
According to both the documentation and the question this should not be the case.
I know that it is possible to use the grailsApplication to access these settings:
def recipient = grailsApplication.config.foo.bar.hello
So I searched my project and found some usages of the grailsApplication, but none related to the log4j settings.
What are other possible reasons of having the log4j settings that are placed in the Config.groovy file used during mvn package? What am I missing?
Update: the mentioned configuration seems to work when I use mvn package to build my project for the first time. Next time I run mvn package, the log4j configuration from the Config.groovy file is used. And if I delete the job workspace, it works well again.