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 2021/01/06 15:51:00 UTC
[jira] [Closed] (LOG4J2-2985) Allow Json based layouts to output a
root element
[ https://issues.apache.org/jira/browse/LOG4J2-2985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Volkan Yazici closed LOG4J2-2985.
---------------------------------
> Allow Json based layouts to output a root element
> -------------------------------------------------
>
> Key: LOG4J2-2985
> URL: https://issues.apache.org/jira/browse/LOG4J2-2985
> Project: Log4j 2
> Issue Type: Improvement
> Components: Layouts
> Reporter: Ron Grabowski
> Assignee: Volkan Yazici
> Priority: Minor
> Fix For: 3.0.0, 2.14.1
>
>
> This request applies to all all Json layouts:
> * https://github.com/apache/logging-log4j2/tree/master/log4j-layout-jackson-json
> * https://github.com/apache/logging-log4j2/tree/master/log4j-layout-jackson
> * https://github.com/apache/logging-log4j2/tree/master/log4j-layout-template-json
> ----
> The layouts in this folder:
> [https://github.com/apache/logging-log4j2/tree/master/log4j-layout-template-json/src/main/resources]
> OutputĀ a structure that looks like this:
> {code}
> {
> "instant": {
> },
> "thread": {
> },
> "level": {
> },
> "loggerName": {
> }
> {code}
> Add a set of new templates and/or a config value to set a root element. Default could be "logEvent" but could be overridden to something else like "data":
> {code}
> {
> "data": {
> "instant": {
> },
> "thread": {
> },
> "level": {
> },
> "loggerName": {
> }
> {code}
> A root element (sometimes?) makes it easier to extract data in 3rd party tools like Splunk's _spath_ command:
> https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath
> Maybe its as simple as calling _withRootName_?
> https://stackoverflow.com/questions/15936680/how-to-rename-root-key-in-json-serialization-with-jackson
> {code}
> final ObjectWriter writer = mapper.writer().withRootName("rootName");
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)