You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Ralph Goers (Jira)" <ji...@apache.org> on 2020/08/02 05:15:00 UTC

[jira] [Commented] (LOG4J2-2863) LocationAwareLogger implementation fails to extract throwable from message

    [ https://issues.apache.org/jira/browse/LOG4J2-2863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17169453#comment-17169453 ] 

Ralph Goers commented on LOG4J2-2863:
-------------------------------------

I am not really sure why the throwable is being extracted from the message in Log4jLogger. I can only speculate that it is being manipulated in the Message somehow. However, I really don't understand what the problem is that is being reported. I don't see where " if no throwable is given but the ParametrizedMessage contains one, it seems it is not properly extracted" applies.  The ParameterizedMessage is being constructed in Log4jLogger so I am not sure what saying it isn't properly being extracted means, nor do I understand how a ParameterizedMessage could contain a Throwable if no Throwable was provided to the log method.

Perhaps it would help if you could provide a test that demonstrates the problem.

> LocationAwareLogger implementation fails to extract throwable from message
> --------------------------------------------------------------------------
>
>                 Key: LOG4J2-2863
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2863
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: SLF4J Bridge
>    Affects Versions: 2.13.3
>            Reporter: Nicolas Pepin-Perreault
>            Priority: Minor
>
> (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|https://github.com/apache/logging-log4j2/blob/7e745b42bda9bf6f8ea681d38992d18036fc021e/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java#L372], 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,



--
This message was sent by Atlassian Jira
(v8.3.4#803005)