gpt4 book ai didi

spring - 如何启用 Ehcache 的日志记录

转载 作者:IT老高 更新时间:2023-10-28 13:57:58 25 4
gpt4 key购买 nike

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

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

添加关注也无济于事

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

Ehcache.xml

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

请建议我解决这个问题。

Ehcache 使用的是 SLF4J 1.6.1,而我的项目使用的是 SLF4J 1.6.4。会不会有什么问题?

谢谢

最佳答案

EhCache 在 DEBUG 级别记录了很多。首先,这个配置片段过滤掉INFO下面的所有日志语句:

<root level="info">

改成

<root level="ALL">

其次

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

需要提高日志记录级别

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

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

关于spring - 如何启用 Ehcache 的日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10705107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com