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:
- I tried creating a
foo-logback.groovybut that is not loading. - Grails 3: External Logback.groovy file
Another resource: https://logback.qos.ch/manual/configuration.html
Basically, there can only be one
logback.groovyorlogback.xmlin the classpath. In order to achieve what you are asking you could use your root project'slogback.groovyand load afoo-logback.groovyusing aGroovyShellinstance (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.groovyfile. For example, instead ofcom.example.FooServiceyou would define it ascom.example.plugin.foo.FooService, and you'd define a log rule for thecom.example.plugin.foopackage.