1

Just like to define custom Bootstrap.groovy or UrlMappings.groovy in a Grails plugin, we can define FooBootstrap.groovy or FooUrlMappings.groovy so that those can be bundled in the plugin because the earlier are excluded by default. http://docs.grails.org/latest/guide/plugins.html#_excluded_artefacts

How can we do the same for logback.groovy? I have a multi-project build where a single Grails plugin is used by 3 different Grails application.

My research & trials:

  1. I tried creating a foo-logback.groovy but that is not loading.
  2. Grails 3: External Logback.groovy file
Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121

1 Answers1

2

Another resource: https://logback.qos.ch/manual/configuration.html

Basically, there can only be one logback.groovy or logback.xml in the classpath. In order to achieve what you are asking you could use your root project's logback.groovy and load a foo-logback.groovy using a GroovyShell instance (see https://stackoverflow.com/a/9006034/260487).

Alternatively you can have the plugin resources defined in its own package and include that package in your root logback.groovy file. For example, instead of com.example.FooService you would define it as com.example.plugin.foo.FooService, and you'd define a log rule for the com.example.plugin.foo package.

Joe
  • 4,585
  • 3
  • 37
  • 51