如何启用Ehcache的日志记录 [英] How to enable logging of Ehcache

查看:313
本文介绍了如何启用Ehcache的日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Spring + Hibernate项目中,我正在使用SLF4J 1.6.4和LogBack进行日志记录.现在,我添加了Ehcache 2.2.0(通过ehcache-spring-annotations-1.1.3).尽管返回了正确的结果,但缓存似乎正在作为方法使用@Cacheable注释,不再执行.但是,我很想看看Ehcache编写的日志.我想,由于Ehcache也使用SLF4J,因此该日志应写入我的日志文件中.但是,这没有发生. logback.xml具有以下内容.

In my Spring + Hibernate project, I was doing logging by SLF4J 1.6.4 with LogBack. Now, I've added Ehcache 2.2.0 (through ehcache-spring-annotations-1.1.3). The caching seems to be working as the method, annotated with @Cacheable, no longer being executed, though returning the correct result. But, I'm interested to see the log written by the Ehcache. As Ehcache also uses SLF4J, I supposed, the log should be written into my log file. But, this is not happening. The logback.xml has the following.

 <root level="info">
    <appender-ref ref="STDOUT"/>
    <appender-ref ref="ROLLING"/>
</root>

添加关注对象也无济于事

Adding following also doesn't help

 <logger name="net.sf.ehcache"> 
</logger> 

Ehcache.xml

Ehcache.xml

    <cache name="sampleCache1"
       eternal="false"
       overflowToDisk="true"
       timeToIdleSeconds="300"
       timeToLiveSeconds="600"           
       memoryStoreEvictionPolicy="LFU"           
        />

请建议我克服此问题.

Please advise me to overcome the problem.

Ehcache使用的是SLF4J 1.6.1,而我的项目使用的是SLF4J 1.6.4.会引起什么问题吗?

The Ehcache is using SLF4J 1.6.1, while my project was using SLF4J 1.6.4. Can it cause any problem?

谢谢

推荐答案

EhCache在DEBUG级别记录了很多日志.首先,此配置代码段筛选出INFO下的所有日志记录语句:

EhCache logs a lot on DEBUG level. First of all, this configuration snippet filters out all logging statements below INFO:

<root level="info">

将其更改为

<root level="ALL">

第二

<logger name="net.sf.ehcache">

需要提高日志记录级别

<logger name="net.sf.ehcache" level="ALL"/> 

然后您应该会看到来自EhCache(和其他)的大量日志记录语句.

You should then see plenty of logging statements from EhCache (and others).

这篇关于如何启用Ehcache的日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆