下面是我的日志配置。它记录的正是我想要的,但它只是将它记录到一个文件中。我想在控制台上看到相同的信息。我尝试了几种变体,但是对于每种变体,我只能将信息记录到控制台或文件中,而不是两者。
def appName = grails.util.Metadata.current.'app.name'
def catalinaBase = System.properties.getProperty('catalina.base')
catalinaBase = catalinaBase ?: "."
def logDirectory = "${catalinaBase}${File.separator}logs${File.separator}${appName}"
// log4j configuration
log4j = {
appenders {
rollingFile name: 'stdout', file: "${logDirectory}${File.separator}${appName}.log".toString(), maxFileSize: '100MB' // Use the same file for stdout and stacktrace
rollingFile name: 'stacktrace', file: "${logDirectory}${File.separator}${appName}.log".toString(), maxFileSize: '100MB' // Use the same file for stdout and stacktrace
}
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',
'net.sf.ehcache.hibernate'
all 'grails.app.controllers.test',
'grails.app.domain.test',
'grails.app.services.test',
'grails.app.taglib.test',
'grails.app.conf.test',
'grails.app.filters.test'
}