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

75 篇文章 0 订阅

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  
<script type="text/javascript">render_code();</script>

 

可以看到命中的信息

代码
  1. [net.sf.ehcache.store.MemoryStore]-[DEBUG] xxx.xxx.XyzCache: xxx.xxx.XyzMemoryStore hit for xxx.xxx.Xyz#8  
<script type="text/javascript">render_code();</script>

 

没命中的信息:

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

<script type="text/javascript">render_code();</script>
大概是这样子的,可以继续进行观察它的详细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...   
<script type="text/javascript">render_code();</script>

 

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 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值