Wednesday, January 25, 2017

Grails Tip Enable SQL Logging

Grails Tip Enable SQL Logging


Here is a great tip while developing a Grails application to enable SQL logging (I would only recommend this in development mode).
In your grails project add the loggingSql = true property to the development closure and that is it. This was using Grails 1.0-RC1.
development {
dataSource {
dbCreate = "create-drop" // one of create, create-drop,update
url = "jdbc:hsqldb:mem:devDB"
loggingSql = true
}
}

Then after starting your app (grails run-app) the SQL will be displayed. I was actually surprised for some reason when the list action was doing a specific select statement like "select title, author from book" rather than "select * from book".

Available link for download