Grails WAR on Tomcat "Log4J" not working at all

I have a log4j DSL configured correctly in my Config.groovy in a grails application. Running the application with grails run-app resets the excellent registration, as I pointed out in the DSL. However, after the war with the grails to create a military file and deploy it to tomcat registration simply disappears. I don’t see it working anywhere except for the tomcat console, showing millions of log statements at the debug level and nothing special for my log file entry.


log4j = {
        appenders {
                 appender new org.apache.log4j.DailyRollingFileAppender(name: "tomcatLog", datePattern: "'.'yyyy-MM-dd", file: "${logDirectory}/snm.log".toString(), layout: pattern(conversionPattern: '[%d{yyyy-MM-dd hh:mm:ss.SSS}] %p %c{5} %m%n'))
        }
        root {
            info 'stdout', 'tomcatLog'
            additivity = true
        }
        info    'grails.app',
                'grails.app.controller',
                'grails.app.bootstrap',
                'grails.app.service',
                'grails.app.task',
                'commons',
                'jsontwitter'
    }

Could you explain the above DSL? He sends commons. * And jsontwitter. * Writes the logs to the specified log file, but no controller, service log is saved in the file.

Thank you Alam Sher

+5
2

, - tomcat. grails-app/conf/Config.groovy:

def catalinaBase = System.properties.getProperty('catalina.base')
if (!catalinaBase) catalinaBase = '.'   // just in case
def logDirectory = "${catalinaBase}/logs"

// default for all environments
log4j = { root ->
     appenders {
             rollingFile name:'stdout', file:"${logDirectory}/${appName}.log".toString(), maxFileSize:'100KB'
             rollingFile name:'stacktrace', file:"${logDirectory}/${appName}_stack.log".toString(), maxFileSize:'100KB'
    }

    error  'org.codehaus.groovy.grails.web.servlet',  //  controllers
           'org.codehaus.groovy.grails.web.pages', //  GSP
           'org.codehaus.groovy.grails.web.sitemesh', //  layouts
           'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
           'org.codehaus.groovy.grails.web.mapping', // URL mapping
           'org.codehaus.groovy.grails.commons', // core / classloading
           'org.codehaus.groovy.grails.plugins', // plugins
           'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
           'org.springframework',
           'org.hibernate'
    root.level = org.apache.log4j.Level.WARN
}

// special settings with production env
environments {
    development {
        log4j = { root ->
            appenders {
                       console name: 'stdout', layout: pattern(conversionPattern: "%d [%t] %-5p %c %x - %m%n")
            }
            warn       'org.codehaus.groovy.grails.web.servlet',  //  controllers
                       'org.codehaus.groovy.grails.web.pages', //  GSP
                       'org.codehaus.groovy.grails.web.sitemesh', //  layouts
                       'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
                       'org.codehaus.groovy.grails.web.mapping', // URL mapping
                       'org.codehaus.groovy.grails.commons', // core / classloading
                       'org.codehaus.groovy.grails.plugins', // plugins
                       'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
                       'org.springframework',
                       'org.hibernate'
            debug  'com.netjay'
            root.level = org.apache.log4j.Level.INFO
        }
    }
}
+7

jira: http://jira.codehaus.org/browse/GRAILS-5666: Run-war classpath.

: , , ""

-1

All Articles