StructuredJsonLayout extends Layout { @Override public String format(LoggingEvent loggingEvent) { final LogRecordBuilder<String> recordBuilder = logRecordBuilderFactory.get(); return recordBuilder.withLevel(loggingEvent.getLevel().toString()) .withLoggerName(loggingEvent.getLoggerName()) .withTimeMs(loggingEvent.getTimeStamp()) .withMessageJson(loggingEvent.getRenderedMessage()) .build(); } StructuredJsonLayout();   StructuredJsonLayout(
      final Supplier<LogRecordBuilder<String>> logRecordBuilderFactory); @Override String format(LoggingEvent loggingEvent); @Override boolean ignoresThrowable(); @Override void activateOptions();  }
@Test public void shouldFormatLogRecordCorrectly() { final String msg = layout.format(loggingEvent); verifyBeforeBuild(builder, io -> io.verify(builder).withLevel(LOG_LEVEL.toString())); verifyBeforeBuild(builder, io -> io.verify(builder).withTimeMs(LOG_TIME_MS)); verifyBeforeBuild(builder, io -> io.verify(builder).withLoggerName(LOGGER_NAME)); verifyBeforeBuild(builder, io -> io.verify(builder).withMessageJson(STRUCTURED_MSG)); assertThat(msg, equalTo(SERIALIZED_MSG)); }