Redirect Grails stacktrace to log4j file

Below is the configuration needed to redirect all stacktrace info to your log4j log file specified. Also you can redirect all console println statements to your log4j

Config.groovy:-


log4j {
appender.stdout = "org.apache.log4j.ConsoleAppender"
appender.'stdout.layout'="org.apache.log4j.PatternLayout"
appender.'stdout.layout.ConversionPattern'='[%r] %c{2} %m%n'
appender.stacktraceLog = "org.apache.log4j.FileAppender"
appender.'stacktraceLog.layout'="org.apache.log4j.PatternLayout"
appender.'stacktraceLog.layout.ConversionPattern'='[%r] %c{2} %m%n'
appender.'stacktraceLog.File'="../logs/ProcessParamEditor.log"
//rootLogger="WARN"
logger {
grails="error"
StackTrace="error,stacktraceLog"
org {
codehaus.groovy.grails.web.servlet="error" // controllers
codehaus.groovy.grails.web.pages="error" // GSP
codehaus.groovy.grails.web.sitemesh="error" // layouts
codehaus.groovy.grails."web.mapping.filter"="error" // URL mapping
codehaus.groovy.grails."web.mapping"="error" // URL mapping
codehaus.groovy.grails.commons="info" // core / classloading
codehaus.groovy.grails.plugins="error" // plugins
codehaus.groovy.grails.orm.hibernate="error" // hibernate integration
springframework="off"
hibernate="off"
}
}
additivity.StackTrace=false
}

environments {
development {
rootLogger="INFO"
log4j{
logger{
org{
org.codehaus.groovy.grails.plugins.searchable="debug"
}
}
}
}
test {
rootLogger="INFO"
log4j = { appenders { file name:'stacktrace', file:"../logs/stacktrace.log".toString() } }
}
production {
rootLogger="WARN"
log4j = { appenders { file name:'stacktrace', file:"../logs/ProcessParamEditor.log".toString() } }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s