Ehcache和日志问题

3
几天前我开始在Web应用程序中使用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个回答

1
要记录put/gets/removes等操作,缓存需要启用统计功能。你可以通过编程或在ehcache.xml中进行控制。

日志选项已启用。据我所知,统计选项仅用于Ehcache监视器。但是,无论如何,它也已启用。 - javagirl
只有在启用统计信息时,缓存未命中和命中的日志记录才会实际记录。net.sf.ehcache.Cache的级别也应该设置为debug。 - Alex Snaps
是的,net.sf.ehcache=DEBUG 在log4j.properties中,但这并没有帮助。 - javagirl
为了对这个答案增加一些细节,在<defaultCache eternal="true" cache entry中添加statistics="true"可以解决我的问题。 - chrismarx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接