开发者

How to monitor Hibernate statistics (cache hits and misses) in a grails app?

开发者 https://www.devze.com 2023-02-08 21:07 出处:网络
By default, Grails uses Hibernate with EHCache as t开发者_开发问答he second level cache.I\'m still learning about how Hibernate works internally and would love to be able to introspect the caches (bot

By default, Grails uses Hibernate with EHCache as t开发者_开发问答he second level cache. I'm still learning about how Hibernate works internally and would love to be able to introspect the caches (both EHCache and anything Hibernate does itself at 'level 1') while the application is running and executing my queries. Are there any Grails plugins or similar that will facilitate this?


Either the grails-melody plugin or the app-info plugin will allow you to see what's in the 2nd level EHCache, as well as lots of other interesting details about the internals of your app.

The hibernate 1st level cache is more transient and as far as I know, there isn't any way to examine it.


You can set you logging level for 'net.sf.ehcache.hibernate' to either info or debug in 'config.groovy'. This should give you plenty of information.


Installing JXM Plugin (http://www.grails.org/plugin/jmx) exposes Hibernate statistics as JMX.

Additionally you may need to enable statistics gathering in DataSource.groovy:

hibernate {
    generate_statistics = true
    ...
} 

After installing the plugin you can connect to your process using for instance jconsole and browse the statistics.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号