Skip to content
Change Application Log Levels via Rabbit MQ messages at Runtime
Groovy Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
grails-app
src/main/groovy/org/grails/plugins
.gitignore
README.md
build.gradle
gradle.properties
gradle.settings
gradlew
grailsw
releases.txt
settings.gradle

README.md

dynamic-logs-with-rabbit

Change Application Log Levels via Rabbit MQ messages at Runtime.

  • Great for large scale systems where you'd like to dynamically change your log levels on multiple application instances without requiring code changes.

Installation

Upon install, this will create a new Rabbit Exchange for you called logLevelExchange of type fanout

Usage

Via Controller

  1. Make sure you have a mapping in UrlMappings to logLevel/$action and any security permissions

  2. A controller LogLevelController and view are provided to change the log levels from. Simply go to http[s]://yourapp.com/logLevel

  3. Simply fill in the form and submit. App Name is the application you would like to change the log level for. LogLevelConsumer matches Grails application.properties "app.name" against the one that is passed in from the form.

NOTE: Highly recommend you lock down logLevel endpoint via Spring Security.

Via Service

  1. Inject logLevelService into your services or controllers :
  2. Create a DynamicLogLevelMsg
  • appName is the Application name you want to target. Uses Grails application.properties "app.name"
  • loggerName is the package or class you would like to change the log level for
  • logLevel is log level as a String you would like to change to: ['ALL','DEBUG','ERROR','FATAL','INFO','OFF','TRACE','WARN']

Example

class Foo {
    def logLevelService

    def changeAllServiceLogLevelsToInfo() {
        logLevelService.send new DynamicLogLevelMsg("myApp", "grails.app.services", "INFO")
    }
}

Contributors

Thanks to Burt Beckwith for his contributions & feedback.

You can’t perform that action at this time.