Grails - Multiple Log4j ConfigurationsThis is a quick tip that I found very useful and - to my knowledge - is not part of the Grails documentation by now. So let's spread the word :-) In one of my Grails projects, we use external configuration files to apply customer specific settings. We have a custom ConfigurationLoader that is used to locate customer-specific configuration files based on the current environment (VM arguments, *.properties file and such). The configuration loader returns a list of additional configuration files which is handed over to grails.config.locations  So far so good. Lately we had the requirement to specify customer-specific Log4J log levels, as various components needed a more fine-grained logging level. In Grails versions prior to Grails 2.0 we could have only satisfied this requirement by completely overriding the log4j variable from Config.groovy in the custom configuration file. Luckily, Ian Roberts introduced a far more elegant way to extend the log4j configuration.
Using a map of closuresAs of Grails 2.0, there is a way to extend the Log4J configuration rather than replacing it. The way to go is to use a log4j variable of type Map<String, Closure> instead of Closure. As you can see in the code listing above, log4j is now treated as map, rather than a single value object. As groovy.util.ConfigObject  extends LinkedHashMap, the log4j entries will be called in the defined order and the resulting configuration entries will be merged. With this patch, we were able to add customer-specific log levels to our external configuration files. If you want to have a look at the corresponding patch introducing this feature, check out .
 Jira GRAILS-7314