Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Grails Profiler Plugin
branch: master

Merge pull request #5 from stokito/patch-1

Code highlighting in
latest commit 7fbe2ba1d0
Peter Ledbrook authored
Failed to load latest commit information.
grails-app Publish snapshots and releases from travis. Only build against OpenJD…
src/java/com/linkedin/grails/profiler Fix indent to use tabs.
test/projects Add grails wrapper
wrapper Add grails wrapper
.classpath added STS project files
.project fixed project name
.travis.yml Attempt to fix broken travis config
Profiler Plugin.ipr Initial implementation of the plugin.
Profiler.iml Added the tag lib, renamed the appender beans, and added a "…
ProfilerGrailsPlugin.groovy Bump to snapshot version Bump plugin version to 0.5-SNAPSHOT.
grailsw Add grails wrapper
grailsw.bat Add grails wrapper

Profiler Plugin

Build Status

Investigating the performance of an application is an important step in improving its usability. The Profiler Plugin makes it easy to collect timing information for several aspects of an application:

  • Requests
  • Controller actions
  • Service methods
  • View generation


grails install-plugin profiler

How to use it

Once the plugin is installed, all you need to do to profile a request is add the "profiler=on" or "profiler=1" parameter to it. For example, to profile a simple GET request:


You may not see any profiling information yet because it depends on your Log4J configuration. All profiling information is logged at the INFO level to the "com.linkedin.grails.ProfilerPlugin" logger, so this simple configuration will have the profiling messages appear in your console:

log4j {
    logger {
        com.linkedin.grails = "info"

It is also possible to place the profiling information in your HTML pages by using this GSP tag:

<g:profilerOutput />

This will simply write out the profiling information collected so far for the current request. For best results it should be included in the layout inside an HTML comment. If you use it directly within a view, the profiling information will lack the timing for the view generation itself.

For more information, go to the plugin portal page.

Disabling the profiler

You can set a configuration option to completely disable the plugin:

grails.profiler.disable = true

This is particularly useful on a per-environment basis, in case you don't want the impact of profiling in production or even development.

Advanced usage

The plugin is designed around a set of Spring beans that can be used directly from within your code if you require. The most useful beans are documented here with their bean names.


This bean implements the com.linkedin.grails.profiler.ProfilerCondition interface and determines whether profiling is active for the current request or not. The default implementation checks the "profiler" parameter, but you can provide your own implementation in resource.groovy for example.

Method Description
doProfiling() Returns true if profiling should be enabled for the current request, otherwise false.


This is the main bean. It sends log messages to all registered appenders while profiling is active. Otherwise it does nothing.

Method Description
startProfiling(String) Starts the profiler and assigns the given label to the log messages.
stopProfiling() Stops the profiler.
isProfiling() Returns true if the profiler is currently active, otherwise false.
logEntry(Class, String) Logs entry to an action/method/whatever.
logExit(Class, String) Logs exit from an action/method/whatever. There should be one call to logExit() for every logEntry().


A special appender that stores its log messages in a buffer so that it can be retrieved from code. Inject the bean into your own and get the output whenever you like!

Method Description
getOutput() Returns the log output currently stored in this appender's buffer.
Something went wrong with that request. Please try again.