1
votes

I am using Groovy and Log4J. I am not a Log4J expert but after searching many sites for answers I thought I had a configuration that should work in the “Config.groovy” file.

Here’s the result: I get console logging. However, the log files named “project.log” and “StackTrace.log” are empty. I also get another file created named “StackTrace.log.1” (2KB size) that contains an exception message (a non-critical error) posted after I run the application.

Questions: Why am I not getting logging messages in the “project.log” and “StackTrace.log” files? Why is a file named “StackTrace.log.1” getting created and written to instead of the stack trace messages getting logged to the “StackTrace.log” file?

Any help or clues as to what I'm doing wrong will be greatly appreciated.

Here is my “Config.groovy” file (log4j portion):

// log4j configuration
log4j = {

    // Set default level for all, unless overridden below.
    root { debug 'stdout', 'file' }

    // Set level for all application artifacts
    info "grails.app"

    error "org.hibernate.SQL", "org.hibernate.type"

    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',
           'net.sf.ehcache.hibernate'

    warn   'org.mortbay.log'

    appenders {
        rollingFile  name: 'file', file:'project.log', maxFileSize:1024, append: true
        rollingFile name: 'stacktrace', file: "StackTrace.log", maxFileSize: 1024, append: true
    }
}
1

1 Answers

0
votes

is it possible that StackTrace.log.1 has been created because the maxFileSize of 1024 has been reached and then the rollingFile?

I would also begin by removing all the class names listed there so that the debug error level defined in the root closure is applied to all loggers and work from there.