Grails 1.1.1 log4j DSL throws MissingMethodException for PatternLayout configuration

grails, log4j, logging

Solution

Turns out I had missed an equals sign in the configuration. The solution was to change:

log4j {
  ...
}

to

log4j = {
  ...
}

Pretty obvious solution once you see it as compared to the examples in the documentation, but when you're getting errors for specific closures/methods within the DSL, the errors don't make it obvious what the real issue is.

Problem

I've upgraded a Grails 1.0.3 app to Grails 1.1.1. I've upgraded the log4j configuration in Config.groovy to conform to the new DSL. However, after defining a ConsoleAppender with a PatternLayout, the application won't start, and instead throws a MissingMethodException with the message: ``` groovy.lang.MissingMethodException: No signature of method: \ groovy.util.ConfigSlurper$_parse_closure5.pattern() is applicable \ for argument types: (java.util.LinkedHashMap) \ values: [[conversionPattern:%d{ISO8601} [%10.10t] [%18.18c] [%5p] - %m%n]] ``` (I broke the above message into multiple lines for readability). My configuration is: ``` environments { development { log4j { appenders { console name: 'myAppender', layout: pattern(conversionPattern: '%d{ISO8601} [%10.10t] [%18.18c] [%5p] - %m%n') ... } root { error 'myAppender' additivity = true } error 'org.codehaus.groovy.grails.plugins', 'org.codehaus.groovy.grails.orm.hibernate', ... } ... } ``` I've tried changing the pattern, adding parentheses for the console() function, but with no success. What's causing this Exception?

Original source