閱讀701 返回首頁    go 阿裏雲 go 技術社區[雲棲]


如何知道Hibernate已經成功運用了二級緩存EhCache

https://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 

最後更新:2017-04-02 00:06:17

  上一篇:go C++資源之不完全導引(完整版)
  下一篇:go [原創]侯佩日記摘錄之一:2000年10月x日