[
https://issues.apache.org/jira/browse/LOG4J2-2856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17118289#comment-17118289
]
Ralph Goers commented on LOG4J2-2856:
-------------------------------------
What version of Log4j are you using?
> Custom fields in JsonLayout should not overwrite existing fields
> ----------------------------------------------------------------
>
> Key: LOG4J2-2856
> URL: https://issues.apache.org/jira/browse/LOG4J2-2856
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Reporter: Luke Bullard
> Priority: Major
>
> When I added custom fields to the JsonLayout, I was expecting these fields to
> be added to the original message. What I instead observed was the following.
>
> The original message, of format:
>
> {
> "thread" : "main",
> "level" : "INFO",
> "loggerName" : "com.ibm.sterling.afc.common.external.PrometheusServlet",
> "message" : "Started the Prometheus Metrics Server",
> "endOfBatch" : true,
> "loggerFqcn" : "org.apache.logging.log4j.spi.AbstractLogger",
> "contextMap" : \{ },
> "instant" : {
> "epochSecond" : 1590165722,
> "nanoOfSecond" : 968000000
> },
> "threadId" : 1,
> "threadPriority" : 5
> }
>
> Became the following format:
>
> {
> "logEvent" : "Started the Prometheus Metrics Server",
> "key1" : "value1",
> "key2" : "value2"
> }
>
>
> Is there a way to add additional fields to a JsonLayout without losing out on
> the other valuable information? The docs don't make this clear if so, and
> trial and error has been fruitless. If this isn't possible, then could this
> functionality be added?
>
> Thank you
--
This message was sent by Atlassian Jira
(v8.3.4#803005)