You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Volkan Yazici (Jira)" <ji...@apache.org> on 2022/06/22 15:26:00 UTC

[jira] [Commented] (LOG4J2-3543) ContextData is not serialised through JsonLayout

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

Volkan Yazici commented on LOG4J2-3543:
---------------------------------------

[As documented in the manual|https://logging.apache.org/log4j/2.x/manual/layouts.html#JSONLayout], you need to set {{properties}} attribute to {{true}} for enabling the MDC support. This said, I strongly advise you to consider using [the JSON *Template* Layout|https://logging.apache.org/log4j/2.x/manual/json-template-layout.html] instead, which is a successor to the JSON Layout and offers superior performance and customizability.

> ContextData is not serialised through JsonLayout
> ------------------------------------------------
>
>                 Key: LOG4J2-3543
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3543
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.17.2
>            Reporter: Florian Bonte
>            Priority: Major
>
> Values that are contained in the ContextData are included in the LogEvent, but when serialised through a JsonLayout, are not present in the resulting JSON string.
> Example:
> !https://i.stack.imgur.com/eGnSU.png!
> Screenshot of a debugger. When a log occurs, the LogEvent object has a reference to the contents of the ContextData.
>  
> Then after passing this LogEvent through the method toSerializable() in the class org.apache.logging.log4j.core.layout.AbstractJacksonLayout, the contextData is absent from the resulting JSON object:
>  
> {
> {{  "instant" : {}}
> {{    "epochSecond" : 1655893941,}}
> {{    "nanoOfSecond" : 869382600}}
> {{  },}}
> {{  "thread" : "AWT-EventQueue-0",}}
> {{  "level" : "INFO",}}
> {{  "loggerName" : "(sensitive)",}}
> {{  "message" : "(sensitive)",}}
> {{  "endOfBatch" : false,}}
> {{  "loggerFqcn" : "org.apache.log4j.Category",}}
> {{  "threadId" : 25,}}
> {{  "threadPriority" : 6}}
> {{}}}
>  
> There does not appear to be a way to include the contextData in the JSON.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)