How to add contextListener to groovy logback configuration?

I want to use LevelChangePropagator as a logback contextListener, as described in the logback manual . However, in my project, logback is configured using groovy, and there is nothing in the official documentation on setting contextListener in groovy. Logback provides a tool to translate the xml configuration to the groovy configuration. I tried, but it just missed the contextListener part.

I found exactly one answer to my question on the journal mailing lists, but the solution does not seem to work for me.

EDIT:
I created a problem in the JIRA journal about missing documentation: http://jira.qos.ch/browse/LOGBACK-979 . However, maybe someone knows the answer?

+7
logback
source share
1 answer

Add this to logback.groovy:

import ch.qos.logback.classic.jul.LevelChangePropagator def lcp = new LevelChangePropagator() lcp.context = context lcp.resetJUL = true context.addListener(lcp) 
+7
source share

All Articles