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

I've found exactly one answer to my question in the logback mailing lists, but solution doesn't seem to be working for me.

EDIT:
I've created an issue in logback JIRA about missing documentation: http://jira.qos.ch/browse/LOGBACK-979. Still, maybe someone knows the 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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top