@Override
  public String doLayout(ILoggingEvent event) {
    StringWriter output = new StringWriter();
    try (JsonWriter json = new JsonWriter(output)) {
      json.beginObject();
      if (!"".equals(nodeName)) {
        json.name("nodename").value(nodeName);
      }
      json.name("process").value(processKey);
      for (Map.Entry<String, String> entry : event.getMDCPropertyMap().entrySet()) {
        if (entry.getValue() != null && !exclusions.contains(entry.getKey())) {
          json.name(entry.getKey()).value(entry.getValue());
        }
      }
      json
        .name("timestamp").value(DATE_FORMATTER.format(Instant.ofEpochMilli(event.getTimeStamp())))
        .name("severity").value(event.getLevel().toString())
        .name("logger").value(event.getLoggerName())
        .name("message").value(NEWLINE_REGEXP.matcher(event.getFormattedMessage()).replaceAll("\r"));
      IThrowableProxy tp = event.getThrowableProxy();
      if (tp != null) {
        json.name("stacktrace").beginArray();
        int nbOfTabs = 0;
        while (tp != null) {
          printFirstLine(json, tp, nbOfTabs);
          render(json, tp, nbOfTabs);
          tp = tp.getCause();
          nbOfTabs++;
        }
        json.endArray();

      }
      json.endObject();
    } catch (Exception e) {
      e.printStackTrace();
      throw new IllegalStateException("BUG - fail to create JSON", e);
    }
    output.write(System.lineSeparator());
    return output.toString();
  }
@Test
  public void test_log_with_message_arguments() {
    LoggingEvent event = new LoggingEvent("org.foundation.Caller", (Logger) LoggerFactory.getLogger("the.logger"), Level.WARN, "the {}", null, new Object[] {"message"});

    String log = underTest.doLayout(event);

    JsonLog json = new Gson().fromJson(log, JsonLog.class);
    assertThat(json.process).isEqualTo("web");
    assertThat(json.timestamp).isEqualTo(DATE_FORMATTER.format(Instant.ofEpochMilli(event.getTimeStamp())));
    assertThat(json.severity).isEqualTo("WARN");
    assertThat(json.logger).isEqualTo("the.logger");
    assertThat(json.message).isEqualTo("the message");
    assertThat(json.stacktrace).isNull();
    assertThat(json.fromMdc).isNull();
  }