use of org.apache.logging.log4j.jackson.AbstractJacksonLayout in project logging-log4j2 by apache.
the class JsonLayoutTest method testIncludeNullDelimiterTrue.
@Test
public void testIncludeNullDelimiterTrue() throws Exception {
final AbstractJacksonLayout layout = JsonLayout.newBuilder().setCompact(true).setIncludeNullDelimiter(true).build();
final String str = layout.toSerializable(LogEventFixtures.createLogEvent());
assertTrue(str.endsWith("\0"));
}
use of org.apache.logging.log4j.jackson.AbstractJacksonLayout in project logging-log4j2 by apache.
the class JsonLayoutTest method testDefaultCharset.
@Test
public void testDefaultCharset() {
final AbstractJacksonLayout layout = JsonLayout.createDefaultLayout();
assertEquals(StandardCharsets.UTF_8, layout.getCharset());
}
use of org.apache.logging.log4j.jackson.AbstractJacksonLayout in project logging-log4j2 by apache.
the class JsonLayoutTest method testLayoutLoggerName.
@Test
public void testLayoutLoggerName() throws Exception {
final boolean propertiesAsList = false;
// @formatter:off
final AbstractJacksonLayout layout = JsonLayout.newBuilder().setLocationInfo(false).setProperties(false).setPropertiesAsList(propertiesAsList).setComplete(false).setCompact(true).setEventEol(false).setCharset(StandardCharsets.UTF_8).setIncludeStacktrace(true).build();
// @formatter:on
// @formatter:off
final Log4jLogEvent expected = Log4jLogEvent.newBuilder().setLoggerName("a.B").setLoggerFqcn("f.q.c.n").setLevel(Level.DEBUG).setMessage(new SimpleMessage("M")).setThreadName("threadName").setTimeMillis(1).build();
// @formatter:on
final String str = layout.toSerializable(expected);
assertTrue(str, str.contains("\"loggerName\":\"a.B\""));
final Log4jLogEvent actual = new Log4jJsonObjectMapper(propertiesAsList, true, false, false).readValue(str, Log4jLogEvent.class);
assertEquals(expected.getLoggerName(), actual.getLoggerName());
assertEquals(expected, actual);
}
use of org.apache.logging.log4j.jackson.AbstractJacksonLayout in project logging-log4j2 by apache.
the class JsonLayoutTest method testContentType.
@Test
public void testContentType() {
final AbstractJacksonLayout layout = JsonLayout.createDefaultLayout();
assertEquals("application/json; charset=UTF-8", layout.getContentType());
}
use of org.apache.logging.log4j.jackson.AbstractJacksonLayout in project logging-log4j2 by apache.
the class JsonLayoutTest method testIncludeNullDelimiterFalse.
@Test
public void testIncludeNullDelimiterFalse() throws Exception {
final AbstractJacksonLayout layout = JsonLayout.newBuilder().setCompact(true).setIncludeNullDelimiter(false).build();
final String str = layout.toSerializable(LogEventFixtures.createLogEvent());
assertFalse(str.endsWith("\0"));
}
Aggregations