2015-02-24 67 views
0

我正在使用资源插件和Log4j进行日志记录的Grails应用程序。我想禁用来自资源插件的日志记录,因为它对我没有用,只是用无用的信息填充我的日志文件。如:如何使用Log4J禁用不同模块的日志记录,例如防止“资源”日志

File [file] changed. Applying changes to application. 
Scheduling reload of resource files due to change of file [file] 
Performing a changed file reload 
Loading declared resources... 
Finished changed file reload 

我不希望这样的信息在我的日志文件作为其不适合我有用的,这使得难以读得在我的日志文件的其他有用的信息。

有没有什么办法可以禁用特定模块的日志记录,如资源

我曾尝试以下解决方法:

off 'grails.app.services.org.grails.plugin.resource', 
'grails.app.taglib.org.grails.plugin.resource', 
'grails.app.resourceMappers.org.grails.plugin.resource' 

但这并没有帮助我。

回答

0

你已经尝试过各种包/类名组合,但没有成功。 由于您的示例日志输出不包含类名称,因此您不知道应该定位什么。如果您修改用于日志消息的格式,则可以看到需要阻止的确切名称。

一个例子:

//time, log level, thread, class, message, newline 
console name: 'myAppender', layout: pattern(conversionPattern: '%d | %p | %t | %c | %m%n') 
root { 
    info 'myAppender' 
} 

一旦你这样做,你应该看到输出类似这样:

2015-02-17 10:53:06,536 | INFO | localhost-startStop-1 | org.hibernate.tool.hbm2ddl.SchemaUpdate | schema update complete 

为了抑制该行输出的,你的目标

org.hibernate.tool.hbm2ddl.SchemaUpdate 
相关问题