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

Allow to easily add fields with fixed values to JSON output

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7, 2.8, 2.8.1, 2.8.2, 2.9.0, 2.9.1
    • Fix Version/s: 2.10.0
    • Component/s: Layouts
    • Labels:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: