You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Christian Kemper (Jira)" <ji...@apache.org> on 2020/01/07 12:26:00 UTC

[jira] [Created] (LOG4J2-2755) Invalid JSON in JsonLayout

Christian Kemper created LOG4J2-2755:
----------------------------------------

             Summary: Invalid JSON in JsonLayout
                 Key: LOG4J2-2755
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2755
             Project: Log4j 2
          Issue Type: Bug
          Components: Layouts
    Affects Versions: 2.11.2
            Reporter: Christian Kemper


Using the log4j2 JsonLayout can result in invalid JSON. Some parsers could not parse this syntax.
 The problem ist the attribute "nanoOfSeconds" from the timestamp:
{code:javascript}
{
  "loggerFqcn": "org.apache.catalina.valves.AccessLogValve",
  "instant": {
    "epochSecond": 1578393313,
    "nanoOfSecond": 008000
  },
  "clientIp": "-",
  "remoteHost": "192.168.0.1",
  "message": "GET /metrics HTTP/1.1",
  "status": 200,
  "size": "50",
  "referer": "-",
  "processTimeMillis": 92
}
{code}
The Attribute "nanoOfSeconds" starts with leading zeros. According to the JSONĀ [rfc4627|https://tools.ietf.org/html/rfc4627] this is an invalid JSON number.

Is it possible to correct this and remove the leading zeros?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)