8 Troubleshooting - Reference Documentation
Authors: Burt Beckwith
Version: 1.2.3
8 Troubleshooting
You can enable logging of the JSON responses from client calls by setting thegrails.plugin.cloudfoundry.Scripts
category to the debug
level in your log4j configuration, e.g.debug 'grails.plugin.cloudfoundry.Scripts'
trace 'grails.plugin.cloudfoundry.ClientWrapper'
trace 'grails.plugin.cloudfoundry' trace 'grails.plugin.cloudsupport' trace 'org.cloudfoundry'
Config.groovy
grails.plugin.cloudfoundry.showStackTrace = true
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.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 Cloud Foundry MySQL/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.converters.JSONclass BootStrap { def init = { servletContext -> String VCAP_SERVICES = System.getenv('VCAP_SERVICES') println "VCAP_SERVICES: ${System.getenv('VCAP_SERVICES')}n" try { def servicesMap = JSON.parse(VCAP_SERVICES) servicesMap.each { key, services -> if (key.startsWith('mysql')) { for (service in services) { print "MySQL service $service.name: " print "url='jdbc:mysql://$service.credentials.hostname:$service.credentials.port/$service.credentials.name', " print "user='$service.credentials.user', " println "password='$service.credentials.password'n" } } else if (key.startsWith('postgresql')) { for (service in services) { print "PostgreSQL service $service.name: " print "url='jdbc:postgresql://$service.credentials.hostname:$service.credentials.port/$service.credentials.name', " print "user='$service.credentials.user', " println "password='$service.credentials.password'n" } } } } catch (e) { println "Error occurred parsing VCAP_SERVICES: $e.message" } } }
Config.groovy
with the grails.dbconsole.enabled
attribute (it's only enabled by default in development):environments {
production {
grails.dbconsole.enabled = true
}
…
}
grails.dbconsole.urlRoot
attribute:environments {
production {
grails.dbconsole.enabled = true
grails.dbconsole.urlRoot = '/admin/dbconsole'
}
…
}
grails cf-logs --stdout