Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails Melody plugin no longer logs SQL calls as of grails 2.0

Ever since I upgraded my two grails projects to grails 2.0 grails-melody stopped logging sql calls. I've tried different versions of the grails-melody plugin, but I get the same error across all versions (even the version that worked before migrating to grails 2.0).

I can't seem to find anything useful googling. If I add a trace debug on the grails melody plugin

log4j = {
    trace 'net.bull.javamelody'
}

I see this in the logs:

DEBUG bull.javamelody  - datasources found in JNDI: []

This problem is really driving me crazy.. Has anyone here experienced this problem? And if so did you find a solution?

UPDATE: Grails melody doesn't even work in newly created projects. I just created a new grails project (grails 2.0.0) with one domain class and corresponding controller and views. Then installed the grails-melody plugin. Inserted some data. When I looked into the monitoring console, no sql data is being logged..

GraphTables

like image 756
Mr.B Avatar asked Mar 21 '12 17:03

Mr.B


1 Answers

A partial workaround is to set jdbc.factory_class in the hibernate section of DataSource.groovy. For example:

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
    jdbc.factory_class = 'net.bull.javamelody.HibernateBatcherFactory'
}

This will log all the SQL queries that go through hibernate. Queries that use the datasource directly still don't get logged.

like image 158
ataylor Avatar answered Sep 30 '22 14:09

ataylor