Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2755

Invalid JSON in JsonLayout

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Invalid
    • 2.11.2
    • None
    • Layouts
    • None

    Description

      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:

      {
        "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
      }
      

      The Attribute "nanoOfSeconds" starts with leading zeros. According to the JSONĀ rfc4627 this is an invalid JSON number.

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

      Attachments

        Activity

          People

            rgoers Ralph Goers
            Afrouper Christian Kemper
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: