Search in sources :

Example 1 with JsonMessage

use of org.apache.logging.log4j.message.JsonMessage in project logging-log4j2 by apache.

the class LoggerTest method flowTracingMessage.

@Test
public void flowTracingMessage() {
    logger.traceEntry(new JsonMessage(System.getProperties()));
    final Response response = new Response(-1, "Generic error");
    logger.traceExit(new JsonMessage(response), response);
    assertEquals(2, results.size());
    assertThat("Incorrect Entry", results.get(0), startsWith("ENTER[ FLOW ] TRACE Enter"));
    assertThat("Missing entry data", results.get(0), containsString("\"java.runtime.name\":"));
    assertThat("incorrect Exit", results.get(1), startsWith("EXIT[ FLOW ] TRACE Exit"));
    assertThat("Missing exit data", results.get(1), containsString("\"message\":\"Generic error\""));
}
Also used : JsonMessage(org.apache.logging.log4j.message.JsonMessage) Test(org.junit.Test)

Example 2 with JsonMessage

use of org.apache.logging.log4j.message.JsonMessage in project logging-log4j2 by apache.

the class LoggerSupplierTest method flowTracing_SupplierOfJsonMessage.

@Test
public void flowTracing_SupplierOfJsonMessage() {
    logger.traceEntry(new Supplier<JsonMessage>() {

        @Override
        public JsonMessage get() {
            return new JsonMessage(System.getProperties());
        }
    });
    assertEquals(1, results.size());
    assertThat("Incorrect Entry", results.get(0), startsWith("ENTER[ FLOW ] TRACE Enter"));
    assertThat("Missing entry data", results.get(0), containsString("\"java.runtime.name\":"));
    assertThat("Bad toString()", results.get(0), not(containsString("JsonMessage")));
}
Also used : JsonMessage(org.apache.logging.log4j.message.JsonMessage) Test(org.junit.Test)

Aggregations

JsonMessage (org.apache.logging.log4j.message.JsonMessage)2 Test (org.junit.Test)2