【问题标题】:Access logs from grails plugins从 grails 插件访问日志
【发布时间】:2014-04-21 23:05:16
【问题描述】:

我们不时喜欢其他人都喜欢使用插件。不幸的是,它们并不总是记录得那么好。有时您很幸运,会发现 OH 调试日志已包含在内。

如何为插件开启日志记录?

如果插件打包成org.plugin.special,下面是我们的日志设置,如何添加呢?

log4j = {
    appenders{
      rollingFile name: "myAppender", maxFileSize: 1024, file:'/development/log/eightstates.log'
      console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n'), threshold: org.apache.log4j.Level.DEBUG
    }
    debug myAppender: [
      'grails.app.controllers.come.example.eightstates',     
      'grails.app.domain.come.example.eightstates',          
      'grails.app.services.come.example.eightstates',       
      'grails.app.taglib.come.example.eightstates',       
      'grails.app.conf.come.example.eightstates',
      'grails.app.filters.come.example.eightstates',
      'grails.app.controllers.org.grails.paypal']
  }

【问题讨论】:

  • 要找出日志的名称,只需在该源代码中打印log.name,然后将其添加到您的 log4j 设置中。

标签: grails logging grails-2.0 grails-plugin


【解决方案1】:

我认为插件没有单个记录器的原因是它依赖于插件中使用的人工制品。例如,如果插件使用控制器,那么用于该控制器的记录器将不同于插件服务中使用的记录器,依此类推。除非插件提供自己的挂钩来启用/禁用日志记录,否则我认为最好的选择是单独启用每个人工制品(这可能需要一段时间)。我不是 100% 确定,但这就是我的经历。

thread 讨论了资源插件的日志记录,如果有帮助的话。

【讨论】:

    猜你喜欢
    • 2011-01-08
    • 2012-10-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 2019-02-21
    • 2011-02-24
    • 2018-01-14
    相关资源
    最近更新 更多