pax-logging-api/Slf4jMDCAdapter uses stale MDC after refreshing service bundle

Description

None

Environment

None

Activity

Show:
Grzegorz Grzybek
January 9, 2018, 12:29 PM

The reproducer is:

A single bundle with single activator with start() method:

Changed logging configuration (added MDC key):

the activator checks for $KARAF_HOME/data/marker file and when found, logs its content and then removes it:

And in logs we can see:

After refreshing pax-logging-service:

We no longer see the key:

Grzegorz Grzybek
January 9, 2018, 12:30 PM

Looks like the most obvious solution is to reinitialize org.ops4j.pax.logging.slf4j.Slf4jMDCAdapter#m_context.

Grzegorz Grzybek
January 9, 2018, 12:52 PM
Grzegorz Grzybek
April 19, 2019, 12:16 PM

Handled with PAXLOGGING-252.

Grzegorz Grzybek
June 3, 2019, 3:37 PM

org.apache.log4j.MDC#getPaxContext, org.ops4j.pax.logging.log4jv2.Log4jv2ThreadContextMap#getContext() and org.ops4j.pax.logging.slf4j.Slf4jMDCAdapter#getContext always delegate to underlying PaxLoggingService (if there's one).

Assignee

Grzegorz Grzybek

Reporter

Grzegorz Grzybek

Fix versions

Labels

None

Components

Affects versions

Priority

Critical
Configure