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

Builder like pattern to add values to MapMessage

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.5
    • Component/s: API
    • Labels:
      None
    • Flags:
      Patch

      Description

      It would be nice to have a builder like pattern to add values to MapMessage and its subclass StructuredDataMessage, so you can do

              EventLogger.logEvent(
                  new StructuredDataMessage(confirm, null, "transfer")
                      .withValue("toAccount", toAccount)
                      .withValue("fromAccount", fromAccount)
                      .withValue("amount", amount)
              );
      

      instead of

              StructuredDataMessage msg = new StructuredDataMessage(confirm, null, "transfer");
              msg.put("toAccount", toAccount);
              msg.put("fromAccount", fromAccount);
              msg.put("amount", amount);
              EventLogger.logEvent(msg);
      

        Attachments

          Activity

            People

            • Assignee:
              mikaelstaldal Mikael Ståldal
              Reporter:
              mikaelstaldal Mikael Ståldal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: