Bugsnag for grails
Groovy Java
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Bugsnag Grails Plugin

Current Version: 0.3

The bugsnag grails plugin integrates the bugsnag client into a grails application and automatically reports errors to the bugsnag service (www.bugsnag.com). Information reported includes a dump of the original request (headers, cookies, query string, original URL, grails environment, etc), the currently logged in user, and a stacktrace of the exception.


compile ":bugsnag:0.3"

Version History

  • 0.3 - added support for 'notifyreleasestages' configuration option. updated to latest bugsnag java client (1.2.8)
  • 0.2 - added metadata customization callback to bugsnagService, added optional extra data map to bugsnagService.notify, added session dump to report
  • 0.1 - first release


Simply enabling the bugsnag plugin automatically configures error reporting capabilities. All uncaught exceptions will be reported to bugsnag.



  grails.plugin.bugsnag.enabled = true
  grails.plugin.bugsnag.apikey = "<bugsnag API key>"

Configuration Parameters

name default description
grails.plugin.bugsnag.enabled false enable or disables bugsnag.
grails.plugin.bugsnag.apikey (not set) API Key provided by bugsnag to report to.

In addition to automatic error reporting, the bugsnag plugin implements bugsnagService which can be used directly in your application to send notifications. The following is an example of how to use bugsnagService to report caught exceptions.

  // in a controller class
  def bugsnagService  // autowired

  // somewhere in a method
  def index() {
      // something breaks
    catch( excp ){
      // handle exception

      def mapOfExtraMetaData = [:] // 
      bugsnagService.notify(request,excp,mapOfExtraMetadData) // assumes you're calling from a controller where the request object is in scope

    //... render something eventually

bugsnagService API

method name description parameters returns
getConfiguredClient Gets a fully configured Client object.
  • context - string used to describe where the exception occurred.
com.bugsnag.Client object
notify sends a configured notification to bugsnag.
  • request - HttpServletRequest
  • exception - java.lang.Exception
  • extraData - (version 0.2+, optional) map of data to include in exception report

version 0.2+

The bugsnagService has the ability to add user-defined metaData to reports. To use this feature, add the bugsnagService to BootStrap.groovy and assign a closure to the addMetadata property. In the closure, add code that assigns values to the provided metaData class instance. The addMetadata closure will be called everytime is notification is sent bugsnag.

example BootStrap.groovy

def bugsnagService

def init = { servletContext ->
  bugsnagService.addMetadata = { metaData ->
    // do an inspection of the current application state
    def customfield1 = "" // assign meaningful value
    def customfield2 = "" // assign meaningful value
    // add the values to the metadata
    metaData.addToTab( "custom", "customfield1", customfield1 )
    metaData.addToTab( "custom", "customfield2", customfield2 )

Implementation Notes

The plugin works by injecting a customized GrailsExceptionResolver into the application context (replacing the default object) which intercepts resolveException and reports using the bugsnagService before calling the superclass.


future versions will include the ability to customize the messages sent to bugsnag to include user defined code.