2011-11-17 113 views
3

幾天前我開始在web應用中使用ehcache。一切都很好,我記得當ehcache在緩存中放入某些東西時,或者從緩存中檢索現有值時 - 它被寫入日誌文件中。 我不知道自那時以來發生了什麼變化,現在ehcache仍然在工作(我在調試模式下仔細檢查了它),但沒有任何記錄。ehcache和日誌記錄問題

這種行爲的原因是什麼?

在我的Maven項目的Ehcache &日誌依賴性列表:

<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-api</artifactId> 
    <version>1.6.1</version> 
</dependency> 
<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-simple</artifactId> 
    <version>1.6.1</version> 
</dependency> 
<dependency> 
    <groupId>com.googlecode.ehcache-spring-annotations</groupId> 
    <artifactId>ehcache-spring-annotations</artifactId> 
    <version>1.2.0</version> 
    <scope>compile</scope> 
</dependency> 
<dependency> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    <scope>provided</scope> 
</dependency> 

我可以保證log4j.properties不是因爲那個時候改變了。

回答

1

要獲取/取得/刪除等等記錄,緩存需要啓用統計。您可以通過編程或ehcache.xml來控制它。

+0

日誌選項已啓用。統計選項AFAIK僅用於ehcache監視器。但是,無論如何,它也啓用了。 – javagirl

+0

僅當啓用統計信息時,關於未命中和命中的高速緩存日誌記錄纔會實際記錄。 net.sf.ehcache.Cache的級別也應在調試中。 –

+0

是的,net.sf.ehcache = DEBUG在log4j.properties中,但它不會幫助 – javagirl