Last updated by dbwhitaker 5 years ago

Debug Plugin

This plugin provides code that runs only in development mode - unless you specifically override it in production in the event of needing some emergency debug!

To install: grails install-plugin debug

Out of the box, it provides the following:

  • logging of request processing start and end, with request processing during
  • configurable logging of various information including the model variables available, request parameters and headers, request attributes, session variables, system information such as free RAM
  • a "control panel" at /debug/ that displays useful application status information and all the information that is logged, but within the browser
  • a taglib for dumping out any category of debug data into a GSP you are debugging
You get console output like this:

filters.DebugFilters Request received from 0:0:0:0:0:0:0:1%0
service.DebugService Request parameters action = info
filters.DebugFilters Total request time: 1242ms

And the extremely-ugly-work-in-progress control panel is here:

Configuration

Logging must be configured to level "info" for logger grails.app.filters:

log4j.logger.grails.app.filters='info'

Debug code only runs in development mode, unless you have set the production override property in Config:

grails.debug.productionOverride=anything

If you set that value to anything other than a blank string, it will keep the debug filters running in production and hence you can log any of the debug info.

During development you can also suppress debug if the request info that is always logged is annoying you:

grails.debug.enabled='false' // only 'false' will turn it off currently in 1.0

You can then configure which categories of debug info are collated and logged:

grails.debug.CATEGORY=false // or true

Where CATEGORY can be anything - you can log your own variables and categories - but by default the following are supported:

  • system - System info like memory and java VM version
  • stats - Request statistics
  • params - Request parameters
  • headers - Request headers
  • controller - Controller info eg controller name and action selected by url mappings
  • session - Session attributes
  • requestAttributes - Request attributes
  • model - contents of the model

Taglib

You can render debug information captured about the request directly into a GSP page you are debugging - provided the category of information has been collected at the time the page is rendered.

Just use the <debug:info/> tag to insert all available info or <debug:info category="params"/> for example to just see the request parameters

Future

There will soon be an object inspector that will operate within the page to inspect values and model variables. debug:info tag rendered sections will also be collapsible.

The control panel has a bunch of unimplemented stuff and needs better layout.

Capture of model data etc for display with debug:info tag within a GSP needs to be implemented. Currently this is captured when the request completes. Some stuff can never be shown in the GSP because it is not known at the time of rendering the view - eg. page render time.