@Test public void testFormatWithoutLoggerName() throws Exception { record.setLoggerName(null); final JsonNode result = objectMapper.readTree(formatter.format(record)); assertThat(result.get("log.logger")).isNull(); }
@Override public String format(final LogRecord record) { final StringBuilder builder = new StringBuilder(); EcsJsonSerializer.serializeObjectStart(builder, record.getMillis()); EcsJsonSerializer.serializeLogLevel(builder, record.getLevel().getName()); EcsJsonSerializer.serializeFormattedMessage(builder, super.formatMessage(record)); EcsJsonSerializer.serializeMDC(builder, mdcSupplier.getMDC()); EcsJsonSerializer.serializeServiceName(builder, serviceName); EcsJsonSerializer.serializeEventDataset(builder, eventDataset); EcsJsonSerializer.serializeThreadId(builder, record.getThreadID()); EcsJsonSerializer.serializeLoggerName(builder, record.getLoggerName()); if (includeOrigin && record.getSourceClassName() != null && record.getSourceMethodName() != null) { EcsJsonSerializer.serializeOrigin(builder, buildFileName(record.getSourceClassName()), record.getSourceMethodName(), -1); } final Throwable throwableInformation = record.getThrown(); if (throwableInformation != null) { EcsJsonSerializer.serializeException(builder, throwableInformation, stackTraceAsArray); } EcsJsonSerializer.serializeObjectEnd(builder); return builder.toString(); }
EcsFormatter extends Formatter { @Override public String format(final LogRecord record) { final StringBuilder builder = new StringBuilder(); EcsJsonSerializer.serializeObjectStart(builder, record.getMillis()); EcsJsonSerializer.serializeLogLevel(builder, record.getLevel().getName()); EcsJsonSerializer.serializeFormattedMessage(builder, super.formatMessage(record)); EcsJsonSerializer.serializeMDC(builder, mdcSupplier.getMDC()); EcsJsonSerializer.serializeServiceName(builder, serviceName); EcsJsonSerializer.serializeEventDataset(builder, eventDataset); EcsJsonSerializer.serializeThreadId(builder, record.getThreadID()); EcsJsonSerializer.serializeLoggerName(builder, record.getLoggerName()); if (includeOrigin && record.getSourceClassName() != null && record.getSourceMethodName() != null) { EcsJsonSerializer.serializeOrigin(builder, buildFileName(record.getSourceClassName()), record.getSourceMethodName(), -1); } final Throwable throwableInformation = record.getThrown(); if (throwableInformation != null) { EcsJsonSerializer.serializeException(builder, throwableInformation, stackTraceAsArray); } EcsJsonSerializer.serializeObjectEnd(builder); return builder.toString(); } }
EcsFormatter extends Formatter { @Override public String format(final LogRecord record) { final StringBuilder builder = new StringBuilder(); EcsJsonSerializer.serializeObjectStart(builder, record.getMillis()); EcsJsonSerializer.serializeLogLevel(builder, record.getLevel().getName()); EcsJsonSerializer.serializeFormattedMessage(builder, super.formatMessage(record)); EcsJsonSerializer.serializeMDC(builder, mdcSupplier.getMDC()); EcsJsonSerializer.serializeServiceName(builder, serviceName); EcsJsonSerializer.serializeEventDataset(builder, eventDataset); EcsJsonSerializer.serializeThreadId(builder, record.getThreadID()); EcsJsonSerializer.serializeLoggerName(builder, record.getLoggerName()); if (includeOrigin && record.getSourceClassName() != null && record.getSourceMethodName() != null) { EcsJsonSerializer.serializeOrigin(builder, buildFileName(record.getSourceClassName()), record.getSourceMethodName(), -1); } final Throwable throwableInformation = record.getThrown(); if (throwableInformation != null) { EcsJsonSerializer.serializeException(builder, throwableInformation, stackTraceAsArray); } EcsJsonSerializer.serializeObjectEnd(builder); return builder.toString(); } EcsFormatter(); }
EcsFormatter extends Formatter { @Override public String format(final LogRecord record) { final StringBuilder builder = new StringBuilder(); EcsJsonSerializer.serializeObjectStart(builder, record.getMillis()); EcsJsonSerializer.serializeLogLevel(builder, record.getLevel().getName()); EcsJsonSerializer.serializeFormattedMessage(builder, super.formatMessage(record)); EcsJsonSerializer.serializeMDC(builder, mdcSupplier.getMDC()); EcsJsonSerializer.serializeServiceName(builder, serviceName); EcsJsonSerializer.serializeEventDataset(builder, eventDataset); EcsJsonSerializer.serializeThreadId(builder, record.getThreadID()); EcsJsonSerializer.serializeLoggerName(builder, record.getLoggerName()); if (includeOrigin && record.getSourceClassName() != null && record.getSourceMethodName() != null) { EcsJsonSerializer.serializeOrigin(builder, buildFileName(record.getSourceClassName()), record.getSourceMethodName(), -1); } final Throwable throwableInformation = record.getThrown(); if (throwableInformation != null) { EcsJsonSerializer.serializeException(builder, throwableInformation, stackTraceAsArray); } EcsJsonSerializer.serializeObjectEnd(builder); return builder.toString(); } EcsFormatter(); @Override String format(final LogRecord record); void setEventDataset(String eventDataset); }
EcsFormatter extends Formatter { @Override public String format(final LogRecord record) { final StringBuilder builder = new StringBuilder(); EcsJsonSerializer.serializeObjectStart(builder, record.getMillis()); EcsJsonSerializer.serializeLogLevel(builder, record.getLevel().getName()); EcsJsonSerializer.serializeFormattedMessage(builder, super.formatMessage(record)); EcsJsonSerializer.serializeMDC(builder, mdcSupplier.getMDC()); EcsJsonSerializer.serializeServiceName(builder, serviceName); EcsJsonSerializer.serializeEventDataset(builder, eventDataset); EcsJsonSerializer.serializeThreadId(builder, record.getThreadID()); EcsJsonSerializer.serializeLoggerName(builder, record.getLoggerName()); if (includeOrigin && record.getSourceClassName() != null && record.getSourceMethodName() != null) { EcsJsonSerializer.serializeOrigin(builder, buildFileName(record.getSourceClassName()), record.getSourceMethodName(), -1); } final Throwable throwableInformation = record.getThrown(); if (throwableInformation != null) { EcsJsonSerializer.serializeException(builder, throwableInformation, stackTraceAsArray); } EcsJsonSerializer.serializeObjectEnd(builder); return builder.toString(); } EcsFormatter(); @Override String format(final LogRecord record); void setEventDataset(String eventDataset);  }