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

Allow to easily add fields with fixed values to JSON output

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7, 2.8, 2.8.1, 2.8.2, 2.9.0, 2.9.1
    • 2.10.0
    • Layouts

    Description

      The Logback JSON Encoder has a feature which allows to specify JSON fields with fixed values. Link: https://github.com/logstash/logstash-logback-encoder#loggingevent_custom_global

      Example:

      <encoder class="net.logstash.logback.encoder.LogstashEncoder">
        <customFields>{"appname":"myWebservice","roles":["customerorder","auth"],"buildinfo":{"version":"Version 0.1.0-SNAPSHOT","lastcommit":"75473700d5befa953c45f630c6d9105413c16fe1"}}</customFields>
      </encoder>
      

      This is a very convenient way to specify fixed attributes like application, service or environment.

      So far I don't see such a possibility in log4j.

      Attachments

        Issue Links

          Activity

            People

              mikaelstaldal Mikael Ståldal
              raimar.falke Raimar Falke
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: