[
https://issues.apache.org/jira/browse/LOG4J2-2139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16276212#comment-16276212
]
Remko Popma commented on LOG4J2-2139:
-------------------------------------
Daniel, I briefly investigated what would be involved to provide a tactical
solution for renaming the "source" key. Looking at the source code for JSON
layout it seems that changing the name of a key is not straightforward.
It can be done, but (unless I'm mistaken) we'd have to make copies of
[LogEventJsonMixIn|https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventJsonMixIn.java]
and
[LogEventWithContextListMixIn|https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/LogEventWithContextListMixIn.java]
just to provide a different value for the {{@JsonProperty}} annotation that
determines the key name. This would be quite ugly.
It could be that there is a cleaner way to do a tactical solution to rename the
{{"source"}} key to something else. I'm not an expert on the Jackson library,
perhaps others can offer alternative ways to accomplish this.
If there is no clean tactical solution perhaps we should focus on a strategic
solution like a Log4j2 plugin for https://github.com/bazaarvoice/jolt to
support custom transformations on the messages generated by our JSON layout.
> JSONLayout ability to rename keys in log output - particularly locationInfo
> "source"
> ------------------------------------------------------------------------------------
>
> Key: LOG4J2-2139
> URL: https://issues.apache.org/jira/browse/LOG4J2-2139
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Reporter: Daniel Kirkdorffer
> Priority: Minor
> Labels: json
>
> We ran into a problem when setting {{locationInfo}} to {{true}} when
> ingesting logs into Kibana. The problem had to do with a conflict with
> another existing key named {{"source"}} of type String, and the fact that
> {{locationInfo}} produces an Object called "source".
> So it would be nice to have a way to supply a different Object name. Perhaps
> this could be broadened so that other key names could also be renamed?
> Maybe there is a way to do this already?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)