Changeset 197


Ignore:
Timestamp:
Nov 27, 2009, 1:49:05 PM (10 years ago)
Author:
gav
Message:

Revamp logging configuration.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/Config.groovy

    r165 r197  
    3636grails.enable.native2ascii = true
    3737
    38 // set per-environment serverURL stem for creating absolute links
    39 environments {
    40     production {
    41         grails.serverURL = "http://www.changeme.com"
     38/**
     39 * Start of log4j configuration.
     40 * Causing this file to reload (e.g. edit/save) may break the appLog destination
     41 * and further logs will be written to files or directories like "[:]"
     42 * For more info see http://logging.apache.org/log4j/1.2/manual.html
     43 * For log levels see http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html
     44 * Basic log levels are ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
     45 */
     46def logDirectory = '.'
     47
     48log4j = {
     49    appenders {
     50        // Use if we want to prevent creation of a stacktrace.log file.
     51        // Beware that since we are using assingment above 'log4j =' this may override things you did not want to.
     52        'null' name:'stacktrace'
     53
     54        // Use this if we want to modify the default appender called 'stdout'.
     55        console name:'stdout', layout:pattern(conversionPattern: '[%t] %-5p %c{2} %x - %m%n')
     56
     57        // Custom log file.
     58        rollingFile name:"appLog",
     59                        file:"${logDirectory}/${appName}.log".toString(),
     60                        maxFileSize:'1MB',
     61                        maxBackupIndex:0,
     62                        layout:pattern(conversionPattern: '%d{[EEE, dd-MMM-yyyy @ HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n')
    4263    }
     64
     65    // Configure the root logger to output to stdout and appLog appenders.
     66    root {
     67        error 'stdout','appLog'
     68        additivity = true
     69    }
     70
     71    // This is for the builtin stuff and from the default Grails-1.1.1 config.
     72    error 'org.codehaus.groovy.grails.web.servlet',  //  controllers
     73            'org.codehaus.groovy.grails.web.pages', //  GSP
     74            'org.codehaus.groovy.grails.web.sitemesh', //  layouts
     75            'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
     76            'org.codehaus.groovy.grails.web.mapping', // URL mapping
     77            'org.codehaus.groovy.grails.commons', // core / classloading
     78            'org.codehaus.groovy.grails.plugins', // plugins
     79            'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
     80            'org.springframework',
     81            'org.hibernate'
     82
     83    warn   'org.mortbay.log' // Jetty
     84
     85    error "grails.app" // Set the default log level for our app code.
     86    info "grails.app.bootstrap" // Set the log level per type and per type.class
     87    debug "grails.app.service"
     88    debug "grails.app.controller"
     89    error "grails.app.service.PersonService"
     90    error "grails.app.service.NavigationService"
    4391}
    4492
    45 // log4j configuration
    46 log4j {
    47     appender.stdout = "org.apache.log4j.ConsoleAppender"
    48     appender.'stdout.layout'="org.apache.log4j.PatternLayout"
    49     appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n'
    50     appender.stacktraceLog = "org.apache.log4j.FileAppender"
    51     appender.'stacktraceLog.layout'="org.apache.log4j.PatternLayout"
    52     appender.'stacktraceLog.layout.ConversionPattern'='[%r] %c{2} %m%n'
    53     appender.'stacktraceLog.File'="stacktrace.log"
    54     rootLogger="error,stdout"
    55     logger {
    56         grails="error"
    57         StackTrace="error,stacktraceLog"
    58         org {
    59             codehaus.groovy.grails.web.servlet="error"  //  controllers
    60             codehaus.groovy.grails.web.pages="error" //  GSP
    61             codehaus.groovy.grails.web.sitemesh="error" //  layouts
    62             codehaus.groovy.grails."web.mapping.filter"="error" // URL mapping
    63             codehaus.groovy.grails."web.mapping"="error" // URL mapping
    64             codehaus.groovy.grails.commons="info" // core / classloading
    65             codehaus.groovy.grails.plugins="error" // plugins
    66             codehaus.groovy.grails.orm.hibernate="error" // hibernate integration
    67             springframework="off"
    68             hibernate="off"
     93/**
     94 * Environment specific configuration.
     95 */
     96environments {
     97
     98    production {
     99        grails.serverURL = "http://www.changeme.com" // Set serverURL stem for creating absolute links.
     100        log4j {
     101            appenders {
     102                // Pickup the Tomcat/Catalina logDirectory else use the current dir.
     103                def catalinaBase = System.properties.getProperty('catalina.base')
     104                logDirectory = catalinaBase ? "${catalinaBase}/logs" : '.'
     105
     106                rollingFile name:"appLog",
     107                                file:"${logDirectory}/${appName}.log".toString(),
     108                                maxFileSize:'1MB',
     109                                maxBackupIndex:0,
     110                                layout:pattern(conversionPattern: '%d{[EEE, dd-MMM-yyyy @ HH:mm:ss.SSS]} [%t] %-5p %c %x - %m%n')
     111
     112            }
     113            error "grails.app" // Set the default log level for our app code.
     114            info "grails.app.bootstrap" // Set the log level per type and per type.class
     115            warn "grails.app.service"
     116            warn "grails.app.controller"
    69117        }
    70118    }
    71     additivity.StackTrace=false
    72 }
    73119
    74 //log4j.logger.org.springframework.security='off,stdout'
     120    development {
     121        grails.serverURL = "http://localhost:8080/${appName}" // Set serverURL stem for creating absolute links.
     122    }
     123
     124    test {
     125        grails.serverURL = "http://localhost:8080/${appName}" // Set serverURL stem for creating absolute links.
     126    }
     127
     128} // end environments
    75129
    76130/** Navigation plugin menu.
Note: See TracChangeset for help on using the changeset viewer.