Peter
Peter

Reputation: 29877

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

By default, Grails uses Hibernate with EHCache as the 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?

Upvotes: 2

Views: 2781

Answers (3)

jrd
jrd

Reputation: 3137

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.

Upvotes: 2

Ben Doerr
Ben Doerr

Reputation: 1655

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.

Upvotes: 2

ataylor
ataylor

Reputation: 66109

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.

Upvotes: 4

Related Questions