How to write console output to a log file in development

Thanks to http://simonpalmer.com/grails-logging/

grails-app/conf/Config.groovy

// log4j configuration
log4j = {
// Example of changing the log pattern for the default console
// appender:
//
//appenders {
// console name:’stdout’, layout:pattern(conversionPattern: ‘%c{2} %m%n’)
//}

appenders {
file name:’file’, file:’/Users/naren/Downloads/logfile.log’, append: false
console name:’stdout’
}

debug ‘grails.app’,
‘alerts’,
‘grails.app.jobs’ //for quartz jobs

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’
‘grails.app’

warn ‘org.mortbay.log’

root {
// change the root logger to my tomcatLog file
error ‘file’, stdout
info ‘file’, stdout
warn ‘file’, stdout
debug ‘file’, stdout
additivity = true
}
}

Leave a comment