2015-02-24 66 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 
相關問題