如何知道Hibernate已经成功运用了二级缓存EhCache

简介: http://yulimin.javaeye.com/blog/30826 问题是DEBUG之后我也不清楚应该看哪里! DEBUG的信息实在是太多,很难看全! 能否给个实例,指出那里显示了使用了二级缓存!   对Log4J进行分类分级一下,我的如下,你可以进行修改: 代码 log4j.threshold = ALL    log4j.rootLogger =

http://yulimin.javaeye.com/blog/30826

问题是DEBUG之后我也不清楚应该看哪里!
DEBUG的信息实在是太多,很难看全!
能否给个实例,指出那里显示了使用了二级缓存!

 

对Log4J进行分类分级一下,我的如下,你可以进行修改:

代码
  1. log4j.threshold = ALL   
  2. log4j.rootLogger = ALL   
  3. #   
  4. log4j.category.org.springframework debug,FrameWorkSpring   
  5. log4j.category.org.hibernate debug,FrameWorkHibernate   
  6. log4j.category.net.sf.ehcache debug,FrameWorkEhCache   
  7.   
  8. log4j.appender.FrameWorkSpring org.apache.log4j.DailyRollingFileAppender   
  9. log4j.appender.FrameWorkSpring.File ${system.logPath}/FrameWorkSpring.log   
  10. log4j.appender.FrameWorkSpring.DatePattern yyyy-MM-dd'.log'   
  11. log4j.appender.FrameWorkSpring.layout org.apache.log4j.PatternLayout   
  12. log4j.appender.FrameWorkSpring.layout.ConversionPattern [%c]-[%p] %m%n   
  13. log4j.appender.FrameWorkSpring.append false  
  14.   
  15. log4j.appender.FrameWorkHibernate org.apache.log4j.DailyRollingFileAppender   
  16. log4j.appender.FrameWorkHibernate.File ${system.logPath}/FrameWorkHibernate.log   
  17. log4j.appender.FrameWorkHibernate.DatePattern yyyy-MM-dd'.log'   
  18. log4j.appender.FrameWorkHibernate.layout org.apache.log4j.PatternLayout   
  19. log4j.appender.FrameWorkHibernate.layout.ConversionPattern [%c]-[%p] %m%n   
  20. log4j.appender.FrameWorkHibernate.append false  
  21.   
  22. log4j.appender.FrameWorkEhCache org.apache.log4j.DailyRollingFileAppender   
  23. log4j.appender.FrameWorkEhCache.File ${system.logPath}/FrameWorkEhCache.log   
  24. log4j.appender.FrameWorkEhCache.DatePattern yyyy-MM-dd'.log'   
  25. log4j.appender.FrameWorkEhCache.layout org.apache.log4j.PatternLayout   
  26. log4j.appender.FrameWorkEhCache.layout.ConversionPattern [%c]-[%p] %m%n   
  27. log4j.appender.FrameWorkEhCache.append false  

 

可以看到命中的信息

代码
  1. [net.sf.ehcache.store.MemoryStore]-[DEBUG] xxx.xxx.XyzCache: xxx.xxx.XyzMemoryStore hit for xxx.xxx.Xyz#8  

 

没命中的信息:

代码
  1. [net.sf.ehcache.Cache]-[DEBUG] xxx.xxx.Xyz cache - Miss   


大概是这样子的,可以继续进行观察它的详细log信息再做分析。 

增加一些信息:

EhCache初始化的信息

代码
  1. [net.sf.ehcache.CacheManager]-[DEBUG] Configuring ehcache from classpath.   
  2. [net.sf.ehcache.config.ConfigurationFactory]-[DEBUG] Configuring ehcache from ehcache.xml found in the classpath: file:xxx/WEB-INF/classes/ehcache.xml   
  3. [net.sf.ehcache.config.ConfigurationFactory]-[DEBUG] Configuring ehcache from URL: file:xxx/WEB-INF/classes/ehcache.xml   
  4. [net.sf.ehcache.config.ConfigurationFactory]-[DEBUG] Configuring ehcache from InputStream   
  5. [net.sf.ehcache.config.DiskStoreConfiguration]-[DEBUG] Disk Store Path: xxx   
  6. [net.sf.ehcache.config.ConfigurationHelper]-[DEBUG] No CacheManagerEventListenerFactory class specified. Skipping...   
  7. [net.sf.ehcache.config.ConfigurationHelper]-[DEBUG] No CachePeerListenerFactoryConfiguration specified. Not configuring a CacheManagerPeerListener.   
  8. [net.sf.ehcache.config.ConfigurationHelper]-[DEBUG] No BootstrapCacheLoaderFactory class specified. Skipping...   

 

EhCache开始工作的信息

代码
  1. [net.sf.ehcache.store.DiskStore]-[DEBUG] Deleting data file xxx.xxx.Xyz.data   
  2. [net.sf.ehcache.store.MemoryStore]-[DEBUG] Initialized net.sf.ehcache.store.LruMemoryStore for xxx.xxx.Xyz   
  3. [net.sf.ehcache.store.LruMemoryStore]-[DEBUG] xxx.xxx.Xyz Cache: Using SpoolingLinkedHashMap implementation   
  4. [net.sf.ehcache.Cache]-[DEBUG] Initialised cache: xxx.xxx.Xyz 
相关文章
|
5月前
|
缓存 NoSQL Java
分布式系列教程(01) -Ehcache缓存架构
分布式系列教程(01) -Ehcache缓存架构
96 0
|
7月前
|
存储 缓存 NoSQL
EhCache缓存
在查询数据的时候,数据大多来自数据库,通常会基于SQL语句的方式与数据库交互,数据库一般会基于本地磁盘IO的形式将数据读取到内存,返回给Java服务端,Java服务端再将数据响应给客户端,做数据展示。
71 0
|
8月前
|
缓存 NoSQL Java
SpringBoot-26-缓存Ehcache的使用
spring缓存(cache)是在Spring3.1开始引入的,但是其本身只提供了缓存接口,不提供具体缓存的实现,其实现需要第三方缓存实现(Generic、EhCache、Redis等)。EhCache、Redis比较常用,使用Redis的时候需要先安装Redis服务器。
66 0
|
8月前
|
缓存 Java 数据库连接
什么是EhCache 缓存
什么是EhCache 缓存
70 0
|
10月前
|
XML 缓存 Java
|
10月前
|
存储 缓存 NoSQL
Java Cache 缓存方案详解及代码-Ehcache
Java Cache 缓存方案详解及代码-Ehcache
389 0
|
11月前
|
XML 缓存 安全
MyBatis-24MyBatis缓存配置【集成EhCache】
MyBatis-24MyBatis缓存配置【集成EhCache】
68 0
|
缓存 前端开发
ehcache jgroups同步,节点重启初始化缓存bug
ehcache jgroups同步,节点重启初始化缓存bug
114 0
|
存储 缓存 Java
【Shiro】5、Shiro整合Ehcache进行热点数据缓存
在 SpringBoot 中整合 Ehcache 非常简单,只需要在启动类加上注解 @EnableCaching,那么就会自动加载默认的 EhcacheManager,从而达到快速使用,那么我们需要在 Shiro 中有自己的 EhcacheManager 对象,我们就需要自己加载属于我们 Shiro 的 EhcacheManager
80 0
|
存储 缓存 NoSQL
学习MyBatis必知必会(9)~缓存机制(一级缓存、二级缓存、第三方缓存技术redis、ehcache)
学习MyBatis必知必会(9)~缓存机制(一级缓存、二级缓存、第三方缓存技术redis、ehcache)
398 0
学习MyBatis必知必会(9)~缓存机制(一级缓存、二级缓存、第三方缓存技术redis、ehcache)