You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Florian Bonte (Jira)" <ji...@apache.org> on 2022/06/22 13:42:00 UTC
[jira] [Updated] (LOG4J2-3543) ContextData is not serialised through JsonLayout
[ https://issues.apache.org/jira/browse/LOG4J2-3543?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Florian Bonte updated LOG4J2-3543:
----------------------------------
Description:
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.
was:
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.
> 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)