import org.slf4j.LoggerFactory
import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.core.util.StatusPrinter
class BootStrap {
def init = { servletContext ->
// Remove the Grails stack trace log appender, as it does not use a rolling appender.
removeStackTraceLogAppender()
}
def destroy = {
}
/**
* Removes the 'stacktraceLog' appender added by Grails. This appender does NOT use a
* rolling file appender and can grow to astronomical sizes if left unattended. Removing
* this log file does not remove any data, as the errors logged to it also get logged
* to the console appender.
*/
private def removeStackTraceLogAppender() {
def logger = LoggerFactory.getLogger('StackTrace')
if(logger) {
def stackTraceAppender = logger.getAppender('stacktraceLog')
if(stackTraceAppender) {
if(logger.detachAppender(stackTraceAppender)) {
println "Grails 'stacktraceLog' log appender removed from configuration."
}
}
}
}
}