Grails Runtime Logging Plugin
Dependency :
compile ":runtime-logging:0.4"
Summary
Allows you to change the logging characteristics (e.g. Level) for common parts of a Grails application at runtime without the need to restart.
Description
Runtime Logging (log4j) Plugin
This plugin allows you to easily control log4j logging at runtime, using a simple GUI interface, without the need to restart your application.NOTE: This is still an alpha release, and should be treated as such. Specifically, beware of releasing it into production as-is, because there is currently no authentication/protection around the function. But see the "Authentication" section below.Plugin features:- Simple GUI interface for controlling log4j settings
- Dynamically change log4j settings without need to restart
- Separately control common parts of the application such as Controllers, Services, SQL etc.
- Uses intuitive names like "SQL", "Services", "Controllers" (rather than class names) to make it easier for newbies.
- Displays the equivalent closure to add to Config.groovy to get the same effect permanently
Setup
Install by adding a dependency in BuildConfig.groovy (be sure to update the version to the latest):plugins {
…
compile ':runtime-logging:0.4'
}http://localhost:8080/app/runtimeLogging
Authentication
The plugin comes with no authentication or security out-of-the-box. Do not use it in production as-is because anyone could switch on logging to maximum and eat all your disk space and probably crash the server.You should use a security plugin, either Spring Security Core or Shiro. If you're using Spring Security Core the approach is different depending on which authentication approach you're using. If you have Requestmap instances in the database, add a new one, e.g.new RequestMap(url: '/runtimelogging/**', configAttribute: 'ROLE_ADMIN').save()staticRules property in Config.groovy, e.g.grails.plugins.springsecurity.controllerAnnotations.staticRules = [ '/runtimelogging/**': ['ROLE_ADMIN'] ]
grails.plugins.springsecurity.interceptUrlMap = [ … '/runtimelogging/**': ['ROLE_ADMIN'] ]
class MyFilters {
def filters = {
authFilter(controller:"runtimeLogging",action:"*") {
before = {
// Define your own isAllowed() logic
if (!isAllowed()) {
render "You Are Not Authorised"
return false
}
return true
}
}
}
}Future plans
- Add authentication
- Add configuration to allow user-controlled categories
- Add environment-specific config so function can be enabled/disabled for production
Release Notes
- v.0.3: Changes submitted by Brad Whitaker add dynamic selectors to allow more granular control of each Controller/Domain/Service present in the application.
- v.0.4: Updated to work with Grails 1.3 and 2.0.