user3675091
user3675091

Reputation: 365

Grails logging domain class not logging to stdout

All my logging statements from Domain Classes never end up in the my 'stdout'.

I thought this line should do the trick:

stdout: 'grails.app.domain',

It works for all other stuff Servics, Cotrollers but not for Domain classes.

log4j = { root->
    appenders {
        console name:'stdout'
        rollingFile name:'file', maxFileSize: 5000000, maxBackupIndex:10, file:"${catalinaBase}" + File.separator + "logs" + File.separator + "tao.log"
        appender new EventLogAppender(source:'SC', name: 'eventLogAppender', layout:new EnhancedPatternLayout(conversionPattern: '%d{DATE} %5p %c{1}:%L - %m%n %throwable{500}'), threshold: org.apache.log4j.Level.ERROR)
    }

    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'

    all file: 'grails.app.controllers',
        stdout:'grails.app.controllers',
        eventLogAppender:'grails.app.controllers'

    all file: 'grails.app.services',
        stdout:'grails.app.services',
        eventLogAppender:'grails.app.services'

    all file: 'grails.app.domain',
        stdout: 'grails.app.domain',
        eventLogAppender:'grails.app.domain'

    all file: 'grails.app.jobs',
        stdout:'grails.app.jobs',
        eventLogAppender: 'grails.app.jobs'

    all file: 'grails.app.conf.Config',
        stdout:'grails.app.conf.Config',
        eventLogAppender:'grails.app.conf.Config'
}

Upvotes: 2

Views: 675

Answers (1)

injecteer
injecteer

Reputation: 20699

For me the class/package "wildcard"-definition were always not clear, till I found a simple trick. In your class add:

println log.name

and the output is the desired class name to be included into the log4j config

Upvotes: 1

Related Questions