Log4jdbc+Grails+Tomcat7
As your Grails application grows in size and popularity you will find yourself with performance and concurrency problems to overcome. As part of this process you will likely find yourself debugging the raw sql sent to the database. Hibernate comes with functionality to do this, but it is not very most user friendly. The most popular tool for sql debugging is P6spy, but an up and coming alternative is Log4jdbc.
Log4jdbc works similar to P6Spy in that you replace your usual sql driver with one provided by the tool.
//driverClassName = "org.h2.Driver"
driverClassName = "net.sf.log4jdbc.DriverSpy"
You then have to make a change to the database connection url. You must add log4jdbc to the protocol component. Log4jdbc should then be able to detect for which driver it is proxying for.
jdbc:log4jdbc:mysql://localhost/mydatabase
Next you need to add appropriately to the logging configuration of your Grails app. Log4jdbc provides lots of options. I like to use j…