4 Troubleshooting - Reference Documentation
Authors: Burt Beckwith
Version: 1.0.1
4 Troubleshooting
Logging
Set the log level of theheroku
, cloud-support
, and/or memcached
plugin classes to debug to view status messages while deploying if you're having issues:log4j = { … debug 'grails.plugin.heroku', 'grails.plugin.memcached', 'grails.plugin.cloudsupport' … }
console and dbconsole plugins
The console and dbconsole plugins are very helpful in diagnosing issues. The console plugin allows you to run arbitrary Groovy code from a web-based console (similar to the Grails/Groovy Swing-based console) and the dbconsole plugin exposes the H2 database's web-based database console (the H2 database console is available in Grails 2.0 by default, so you only need the plugin in pre-2.0 apps). The great thing about H2's database console is that it doesn't work for just H2 - it works for any JDBC database you have a driver for.Add a reference to the console plugin inBuildConfig.groovy
:plugins { … compile ':console:1.1' }
plugins { … compile ':dbconsole:1.1' }
grails.dbconsole.enabled
attribute in the production section of Config.groovy
:production {
…
grails.dbconsole.enabled = true
…
}
These plugins are very dangerous if left exposed to the public. Be sure to guard them with security if you use them.One issue you'll see is that it's tricky to know how to connect to your PostgreSQL database from the database console. You can use the console plugin to inspect the config settings, but it's more convenient to add this code to your application's
BootStrap.groovy
:import grails.plugin.heroku.PostgresqlServiceInfoclass BootStrap { def init = { servletContext -> String DATABASE_URL = System.getenv('DATABASE_URL') if (DATABASE_URL) { try { PostgresqlServiceInfo info = new PostgresqlServiceInfo() println "nPostgreSQL service ($DATABASE_URL): url='$info.url', " + "user='$info.username', password='$info.password'n" } catch (e) { println "Error occurred parsing DATABASE_URL: $e.message" } } } }
$ heroku logs
<h:dbconsoleLink>Database Console (autologin)</h:dbconsoleLink>