如何为 grails 插件配置日志记录? [英] How do I configure logging for a grails plugin?

查看:31
本文介绍了如何为 grails 插件配置日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建我的第一个 grails 插件,但我不知道应该在哪里配置日志记录.
在普通的 grails 应用程序中,有一个 conf/Config.groovy 文件,但对于插件则没有.
有没有另一种方法来实现这一目标?
我希望在启动插件单元和集成测试时看到调试消息...

I'm creating my first grails plugin and I don't know where the logging should be configured.
In a normal grails app, there is a conf/Config.groovy file for that, but for a plugin there is none.
Is there another way to achieve this ?
I would like to see debug messages when I launch my plugin unit and integration tests...

提前致谢.
菲利普

Thanks in advance.
Philippe

推荐答案

create-plugin 脚本不会创建 Config.groovy,但如果您自己创建,它将被使用.不要从现有应用程序复制一个,因为它会被不适用的东西弄得乱七八糟,只需创建一个 log4j 闭包和您需要的任何其他属性:

The create-plugin script doesn't create a Config.groovy but if you create one yourself it will be used. Don't copy one from an existing app since it'll be cluttered with stuff that isn't applicable, just create a log4j closure and whatever other properties you need:

log4j = {
    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'

    warn   'org.mortbay.log'
}

myplugin.someproperty = 'foo'

这篇关于如何为 grails 插件配置日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆