Ron Grabowski created LOG4J2-2985:
-------------------------------------

             Summary: 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


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)

Reply via email to