Grails:将调试日志记录发送到标准输出

时间:2011-04-08 14:35:10

标签: logging grails

当我从IDE运行Grails应用程序时,我希望输出转到IDE控制台并处于Trace级别。

在grails-app / conf / Config.groovy中,我尝试过一些不起作用的东西,比如:

environments {
    development {
        log4j.rootLogger="trace,stdout"
    }
}

我做错了什么?

1 个答案:

答案 0 :(得分:3)

我想你可以这样试试:

log4j = {
    appenders {
        console name: "stdout", layout: pattern(conversionPattern: "%c{2} %m%n")
        // This if you need different settings per environment
        environments {                  
            production {
                rollingFile name: "myAppender", maxFileSize: 1024, file: "/tmp/logs/myApp.log"
            }
        }
    }

    root {
        trace "stdout"
    }

    // we are saying default is trace for the console, 
    // but for this package we are setting default as debug
    debug "grails.app.controller"

    environments {
        production {
            // Override previous setting for 'grails.app.controller'
            error "grails.app.controller"
        }
    }
}

可以在Grails docs中找到更多示例进行日志记录。

希望这有帮助!