Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-409

LoggingEvent casts to LogbackMDCAdapter without checking

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 0.9.30
    • 0.9.28
    • None
    • None

    Description

      LoggingEvent has this code:

      // ugly but under the circumstances acceptable
      LogbackMDCAdapter logbackMDCAdapter = (LogbackMDCAdapter) MDC
      .getMDCAdapter();
      mdcPropertyMap = logbackMDCAdapter.getPropertyMap();

      I'm trying to build a logback implementation of the OSGi pax-logging-service (http://www.ops4j.org/projects/pax/logging/index.html). But I've got a problem that PAX exports org.slf4j.impl with their own MDC adapter that fails this cast. Theirs has the nice feature that the OSGi bundle context is automatically added to the MDC (at a performance cost, alas). I'd like to see LoggingEvent changed to something like the following for improved flexibility:

      MDCAdapter mdc = MDC.getMDCAdapter();
      if (MDCAdaptor instanceof LogbackMDCAdapter)
      mdcPropertyMap = ((LogbackMDCAdapter)mdc).getPropertyMap();
      else
      mdcPropertyMap = mdc.getCopyOfContextMap();

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            chrisdolan Chris Dolan
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: