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

Make header and footer values customizable in JSONLayout


    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.6
    • Component/s: Layouts
    • Labels:


      It will be helpful to provide a way to customize header and footer in JSONLayout in Log4j 2.

      For instance user is writing a logging application which logs requests and responses to/from a server to log files in JSON format. Now user also wants to log server specific information in each log file but since it will be common for all request/response, it is not desired to be logged with each log entry so user wants to add server specific common information at start of the file. As header in JSON format or in this use case. This will be followed by each request and response logged as a JSON array element. And at rollover this JSON array and main JSON object (which contains header and JSON array) should be closed with help of footer.

      A typical file will be something like ...

      {"Message":"Request message1","RequestingAddress":"","TimeStamp":"2016-01-05_07-24-59"},
      {"Message":"Request message1","RequestingAddress":"","TimeStamp":"2016-01-05_07-24-59"},
      {"Message":"Request message1","RequestingAddress":"","TimeStamp":"2016-01-05_07-24-59"},


        1. log4j2.xml
          0.5 kB
          Anshu Garg
        2. Log4j2-1244JSONTest.log
          0.8 kB
          Anshu Garg
        3. logging-log4j2.patch
          42 kB
          Gary Gregory



            • Assignee:
              garydgregory Gary Gregory
              iha Anshu Garg
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: