2009年4月24日金曜日

[Grails]Grails1.1 Setup fo the Apache Log4j Logging

Sample Setup fo the Apache Log4j Logging on Grails 1.1, A new Log4j DSL is available on Grails 1.1.
  • References
  • Sample Setup in grails-app/conf/Config.goovy file
    This sample setup is modified based on the document(http://d.hatena.ne.jp/nobeans/20090323/1237826907, this documentation is written in Japanese).
    // log4 setup
    log4j = {
    appenders {
    //override the setuf of the default console out
    console(name:'stdout', layout:pattern(conversionPattern: '%d{HH:mm:ss} [%p] (%c{2}) %m%n'))

    //override the setup of the default log
    rollingFile(name:'file', file:'logs/debug.log', maxFileSize:'10MB', maxBackupIndex:5, layout:pattern(conversionPattern: '%d{HH:mm:ss} [%p] (%c{2}) %m%n'))

    //override the setup of the default error stack
    rollingFile(name:'stacktrace', file:'logs/stacktrace.log', maxFileSize:'10MB', maxBackupIndex:5, layout:pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss} [%p] (%c{2}) %m%n'))

    //daily rolling log
    appender new org.apache.log4j.DailyRollingFileAppender(name:'dailyRollingFile', datePattern:"'.'yyyy-MM-dd",layout:pattern(conversionPattern: '%d{HH:mm:ss} [%p] (%c{2}) %m%n'), file:'logs/daily.log');
    }

    root {
    error 'stdout', 'file'
    additivity = false
    }

    //controller
    error 'org.codehaus.groovy.grails.web.servlet'
    //gsp
    error 'org.codehaus.groovy.grails.web.pages'
    //layouts
    error 'org.codehaus.groovy.grails.web.sitemesh'
    //url mapping filter
    error 'org.codehaus.groovy.grails."web.mapping.filter'
    //url mapping
    error 'org.codehaus.groovy.grails."web.mapping'
    //core, classloader
    error 'org.codehaus.groovy.grails.commons'
    //plugins
    error 'org.codehaus.groovy.grails.plugins'
    //hibernate integration
    error 'org.codehaus.groovy.grails.orm.hibernate'
    error 'org.springframework'
    //info 'org.springframework.security'
    //hibernate
    error 'org.hibernate'

    //jetty
    warn 'org.mortbay.log'

    //error stack
    error(
    additivity:false
    //,stdout:"StackTrace"
    ,stacktrace:"StackTrace"
    )

    //debug for my my app
    //info dailyRollingFile:"grails.app.controller.TestController"
    info(
    additivity:false
    //,stdout:"grails.app.controller"
    ,dailyRollingFile:"grails.app.controller"
    )
    info(
    additivity:false
    ,dailyRollingFile:"grails.app.service"
    )
    info(
    additivity:true
    ,dailyRollingFile:"grails.app.task"
    )
    }



0 件のコメント: