mmjmanders
mmjmanders

Reputation: 1553

Output log of single class to file in Grails

I'm trying to redirect the log4j output of a single package to a file. My configuration is as follows:

log4j = {

    appenders {
        console name:'stdout'
        appender new DailyRollingFileAppender(
                name: 'audit',
                datePattern: "'.'yyyy-MM-dd",
                fileName: "${userHome}/${applicationName}.log",
                layout: pattern(conversionPattern: '%d [%t] %-5p %c{2} %x - %m%n')
        )
    }

    root {
        error 'stdout'          
    }

    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',
            'StackTrace',
            'org.hibernate.type',
            'org.hibernate.SQL',
            'Hibernate',
            'org.hibernate.type.descriptor.sql.BasicBinder'

    debug   'grails.app' // set logging for all grails artifacts

    info    audit:
            'my.package.name', additivity: false        
}

Somehow the logging of the my.package.name package is not written to the file but to stdout. When I put the audit logger in my root config the logging gets written to the file but the logging of the other classes is also written in this file, which I don't want.

I want ONLY the logging output of my.package.name to be written to the file, all other logging can go to stdout. I've tried playing with the additivity but I can't figure it out.

Upvotes: 2

Views: 597

Answers (1)

mmjmanders
mmjmanders

Reputation: 1553

I solved it by changing my.package.name to grails.app.my.package.name.

Upvotes: 2

Related Questions