Posted By

traneHead on 02/17/12


Tagged

grails


Versions (?)

Grails log4j for different environments - an example


 / Published in: Groovy
 

An example of a grails (2.x) log4j configuration (in grails-app/conf/Config.groovy).

  1. environments {
  2.  
  3. development {
  4. log4j = {
  5. appenders {
  6. file name: 'grailsfile', file: 'target/grails.log'
  7. file name: 'rootlog', file: 'target/root.log'
  8. file name: 'devfile', file: 'target/development.log',
  9. layout: pattern(conversionPattern: "[%d{HH:mm:ss:SSS}] %-5p %c{2}: %m%n")
  10. }
  11. root { error 'stdout', 'rootlog' }
  12. info additivity: false, grailsfile: 'org.codehaus.groovy.grails.commons'
  13. all additivity: false, devfile: [
  14. 'grails.app.controllers.your.package',
  15. 'grails.app.domain.your.package',
  16. 'grails.app.services.your.package',
  17. 'grails.app.taglib.your.package',
  18. 'grails.app.conf.your.package',
  19. 'grails.app.filters.your.package'
  20. ]
  21. }
  22. }
  23.  
  24. test {
  25. log4j = {
  26. appenders {
  27. file name: 'grailsfile', file: 'target/grails.log'
  28. file name: 'rootlog', file: 'target/root.log'
  29. file name: 'testfile', file: 'target/test.log',
  30. layout: pattern(conversionPattern: "[%d{HH:mm:ss:SSS}] %-5p %c{2}: %m%n")
  31. }
  32. root { error 'stdout', 'rootlog' }
  33. info additivity: false, grailsfile: 'org.codehaus.groovy.grails.commons'
  34. all additivity: false, testfile: [
  35. 'grails.app.controllers.your.package',
  36. 'grails.app.domain.your.package',
  37. 'grails.app.services.your.package',
  38. 'grails.app.taglib.your.package',
  39. 'grails.app.conf.your.package',
  40. 'grails.app.filters.your.package'
  41. ]
  42.  
  43. }
  44. }
  45. production {
  46. grails.logging.jul.usebridge = false
  47. log4j = {
  48. root { error()
  49. }
  50.  
  51. }
  52. }
  53. }

Report this snippet  

You need to login to post a comment.