Grails provide you to log all the hibernate queries by setting logSql=true in the DataSource.groovy file like:
environments { development { dataSource { ... logSql = true } } ...
But native SQL queries are not logged.
To log the SQL queries add groovy.sql in you log4j configurations in Config.groovy file
log4j = { ... debug 'groovy.sql' ... }
and add log level in BootStrap.groovy
import groovy.sql.Sql import java.util.logging.Level class BootStrap { def init = { servletContext -> Sql.LOG.level = Level.FINE ... } def destroy = {} }
that’s all, run your application and you got all native SQL queries in the logs.
Recent Comments