We use grails.config.locations to pull in (optional) settings from a file external to the app. Is there a good way to detect that this file was loaded, either in Bootstrap.groovy or within Config.groovy itself?
Config.groovy has this:
grails.config.locations = [
"file:${userHome}/.grails/${appName}-config.groovy"
]
It'd be nice to know if Grails found and read in this file.
You may be seeing this when turning Grails debug mode, but you don't want to do that. I am using the following strategy. First I check if the file exists:
def externalConfigFile = "${userHome}/.grails/${appName}-config.groovy"
if (new File(externalConfigFile).exists()) {
grails.config.locations << "file:" + externalConfigFile
log.info "External configuration file found at ${externalConfigFile} ..."
}
And then in the file itself I just log that it was run:
log.info 'External config file was loaded.'
So now I can see in the logs upon startup that I found an external configuration file, it is an existing file, and the file was run by Grails, so it is loaded.
I haven't found anything better as yet.