jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Grails Log
  • GLOG-3

Regression? Log4j DSL Cannot be overriden by external config

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Labels:
    None
  • Environment:
    Mac OSX

Description

Prior to Grails 1.1 (at least through 1.0.4), the Log4j configuration could be modified through additional log4j closures in external configuration files. This allowed developers to customize log4j for their own development sandbox (environments 'development' and 'test') without affecting the logging of any other developer or a CI build/test/run cycle.

The Grails 1.1 Log4j DSL appears to fatally fail, quietly, and abort processing of an external config if the config contains ANY {log4j} DSL.

The attached example simply takes the 'appenders' example from the standard Config.groovy and moves it to an external configuration file.

${user.home}/.grails/log4j-external-config-config.groovy
println "log4j-external-config-config: loading"

println "log4j-external-config-config: done"

Here's the output when grails run-app is executed:

kgentle@zeta $ grails run-app
{{Welcome to Grails 1.1 - http://grails.org/}}
Licensed under Apache Standard License 2.0
Grails home is set to: /Library/Grails/Versions/1.1.0

Base Directory: /Users/kgentle/Workspaces/IntelliJ IDEA 8.1/log4j-external-config
Running script /Library/Grails/Versions/1.1.0/scripts/RunApp.groovy
Environment set to development
log4j-external-config-config: loading
Running Grails application..
{{Server running. Browse to http://localhost:8080/log4j-external-config}}

However, adding the following to {{${user.home}/.grails/log4j-external-config-config.groovy}} causes the processing of the external configuration to fail - the trailing println is not executed.

${user.home}/.grails/log4j-external-config-config.groovy
println "log4j-external-config-config: loading"

log4j {
      appenders	{
	  console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
      }
}

println "log4j-external-config-config: done"

Here's the output when grails run-app is executed:

kgentle@zeta $ grails run-app
{{Welcome to Grails 1.1 - http://grails.org/}}
Licensed under Apache Standard License 2.0
Grails home is set to: /Library/Grails/Versions/1.1.0

Base Directory: /Users/kgentle/Workspaces/IntelliJ IDEA 8.1/log4j-external-config
Running script /Library/Grails/Versions/1.1.0/scripts/RunApp.groovy
Environment set to development
log4j-external-config-config: loading
Running Grails application..
{{Server running. Browse to http://localhost:8080/log4j-external-config}}

Note the missing 'log4j-external-config-config: done'

Needless to say, the log4j configuraiton is not changed in any way.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Hide
    Zip Archive
    log4j-external-config-bug-report-17032009.zip
    17/Mar/09 6:57 AM
    19 kB
    Ken Gentle
    1. File
      grails-app/conf/BootStrap.groovy 0.1 kB
    2. File
      grails-app/conf/Config.groovy 3 kB
    3. File
      grails-app/conf/DataSource.groovy 0.6 kB
    4. File
      grails-app/conf/UrlMappings.groovy 0.2 kB
    5. File
      grails-app/conf/spring/resources.groovy 0.0 kB
    6. File
      grails-app/i18n/messages.properties 3 kB
    7. File
      grails-app/i18n/messages_de.properties 3 kB
    8. File
      grails-app/i18n/messages_es.properties 3 kB
    9. File
      grails-app/i18n/messages_fr.properties 2 kB
    10. File
      grails-app/i18n/messages_it.properties 2 kB
    11. File
      grails-app/i18n/messages_ja.properties 2 kB
    12. File
      grails-app/i18n/messages_nl.properties 3 kB
    13. File
      grails-app/.../messages_pt_BR.properties 3 kB
    14. File
      grails-app/i18n/messages_ru.properties 4 kB
    15. File
      grails-app/i18n/messages_th.properties 5 kB
    16. File
      grails-app/.../messages_zh_CN.properties 2 kB
    17. File
      grails-app/views/error.gsp 2 kB
    18. File
      grails-app/views/index.gsp 0.9 kB
    19. File
      grails-app/views/layouts/main.gsp 0.7 kB
    20. XML File
      test/reports/TESTS-TestSuites.xml 0.1 kB
    21. HTML File
      test/reports/html/all-tests.html 0.8 kB
    22. HTML File
      test/reports/html/allclasses-frame.html 0.4 kB
    23. HTML File
      test/reports/html/alltests-errors.html 0.8 kB
    24. HTML File
      test/reports/html/alltests-fails.html 0.9 kB
    25. HTML File
      test/reports/html/index.html 0.7 kB
    26. HTML File
      test/reports/html/overview-frame.html 0.4 kB
    27. HTML File
      test/reports/html/overview-summary.html 2 kB
    28. File
      test/reports/html/stylesheet.css 0.9 kB
    Download Zip
    Show
    Zip Archive
    log4j-external-config-bug-report-17032009.zip
    17/Mar/09 6:57 AM
    19 kB
    Ken Gentle
  2. File
    log4j-external-config-config.groovy
    17/Mar/09 6:57 AM
    0.2 kB
    Ken Gentle

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Ken Gentle added a comment - 17/Mar/09 8:05 AM

Additional information:

Stepping through the Intellij IDEA debugger,

In org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper
on line 118 during the call config.merge(newConfig)

the following exception is thrown

groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.pattern() is applicable for argument types: (java.util.LinkedHashMap) values: [[conversionPattern:%c{2} %m%n]]

and caught by the block on lines 130 - 134

} catch (Exception e) {
                        LOG.warn "Unable to load specified config location $location : ${e.message}"
                        LOG.debug "Unable to load specified config location $location : ${e.message}", e
                    }
                }

where the exception should be logged. Note, however, (if I'm understanding the process correctly), logging is still being configured and the log statements won't be affected at all by the log4j configuration in Config.groovy. How does one get these messages to appear on the console?

Show
Ken Gentle added a comment - 17/Mar/09 8:05 AM Additional information: Stepping through the Intellij IDEA debugger, In org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper on line 118 during the call config.merge(newConfig) the following exception is thrown
groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.pattern() is applicable for argument types: (java.util.LinkedHashMap) values: [[conversionPattern:%c{2} %m%n]]
and caught by the block on lines 130 - 134
} catch (Exception e) {
                        LOG.warn "Unable to load specified config location $location : ${e.message}"
                        LOG.debug "Unable to load specified config location $location : ${e.message}", e
                    }
                }
where the exception should be logged. Note, however, (if I'm understanding the process correctly), logging is still being configured and the log statements won't be affected at all by the log4j configuration in Config.groovy. How does one get these messages to appear on the console?
Hide
Permalink
Ken Gentle added a comment - 17/Mar/09 8:10 AM

Cut & Paste got me again.

That first example in the description should be:

gentle@zeta $ grails run-app
{{Welcome to Grails 1.1 - http://grails.org/}}
Licensed under Apache Standard License 2.0
Grails home is set to: /Library/Grails/Versions/1.1.0
{{ }}
Base Directory: /Users/kgentle/Workspaces/IntelliJ IDEA 8.1/log4j-external-config
Running script /Library/Grails/Versions/1.1.0/scripts/RunApp.groovy
Environment set to development
log4j-external-config-config: loading
log4j-external-config-config: done
Running Grails application..
{{Server running. Browse to http://localhost:8080/log4j-external-config}}

Show
Ken Gentle added a comment - 17/Mar/09 8:10 AM Cut & Paste got me again. That first example in the description should be:
gentle@zeta $ grails run-app {{Welcome to Grails 1.1 - http://grails.org/}} Licensed under Apache Standard License 2.0 Grails home is set to: /Library/Grails/Versions/1.1.0 {{ }} Base Directory: /Users/kgentle/Workspaces/IntelliJ IDEA 8.1/log4j-external-config Running script /Library/Grails/Versions/1.1.0/scripts/RunApp.groovy Environment set to development log4j-external-config-config: loading log4j-external-config-config: done Running Grails application.. {{Server running. Browse to http://localhost:8080/log4j-external-config}}

People

  • Assignee:
    Unassigned
    Reporter:
    Ken Gentle
Vote (5)
Watch (7)

Dates

  • Created:
    17/Mar/09 6:57 AM
    Updated:
    17/Mar/09 8:10 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.