Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2863

LocationAwareLogger implementation fails to extract throwable from message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.13.3
    • None
    • SLF4J Bridge
    • None

    Description

      (Note: I looked but didn't see any issues for this - though I had a hard time coming up with a quick summary, so maybe I didn't search for the right things, sorry in advance if this is a duplicate)

       

      When using the SLF4J bridge's Log4JLogger class as a LocationAwareLogger, if no throwable is given but the ParametrizedMessage contains one, it seems it is not properly extracted.

       

      One thing I saw, is at org.apache.logging.slf4j.Log4JLogger:372, it seems there's a check if we're already passing a throwable, and we only pick up the one from the message if we already are. Is this intentional, and if so, what's the reasoning? From looking at ParametrizedMessage, it seems the throwable is picked up from the message arguments iff there was no throwable initially given, but maybe I misunderstood this.

       

      The use case here is that we have a delegating logger class, but we want the location to be properly computed, so we need to access the logger as a LocationAwareLogger.

       

      Cheers,

      Attachments

        Activity

          People

            Unassigned Unassigned
            npepinpe Nicolas Pepin-Perreault
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: