从grails插件访问日志
有时我们像其他人一样喜欢使用插件。不幸的是,它们并非总是记录得那么好。有时你会幸运地发现调试日志已经包含在内 如何打开插件的日志记录 如果插件是打包的从grails插件访问日志,grails,logging,grails-2.0,grails-plugin,Grails,Logging,Grails 2.0,Grails Plugin,有时我们像其他人一样喜欢使用插件。不幸的是,它们并非总是记录得那么好。有时你会幸运地发现调试日志已经包含在内 如何打开插件的日志记录 如果插件是打包的org.plugin.special,下面是我们的日志设置,我们如何添加它 log4j = { appenders{ rollingFile name: "myAppender", maxFileSize: 1024, file:'/development/log/eightstates.log' console n
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']
}
我认为插件没有一个单独的记录器是因为它依赖于插件中使用的人工制品。例如,如果插件使用控制器,那么该控制器的记录器将不同于插件服务中使用的记录器,等等。除非插件提供了自己的钩子来启用/禁用日志记录,否则我认为最好的办法是单独启用每个工件(这可能需要一段时间)。我不是100%确定,但这是我的经历
这是关于资源插件的日志记录,如果有帮助的话。要找到日志的名称,在源代码中只需打印
log.name
,然后将其添加到log4j设置中。