use of org.apache.logging.log4j.core.Logger in project logging-log4j2 by apache.
the class CsvParameterLayoutTest method testLogJsonArgument.
@Test
public void testLogJsonArgument() throws InterruptedException {
final ListAppender appender = (ListAppender) init.getAppender("List");
appender.countDownLatch = new CountDownLatch(4);
appender.clear();
final Logger logger = (Logger) LogManager.getRootLogger();
final String json = "{\"id\":10,\"name\":\"Alice\"}";
logger.error("log:{}", json);
// wait until background thread finished processing
final int msgCount = 1;
if (appender.getMessages().size() < msgCount) {
appender.countDownLatch.await(5, TimeUnit.SECONDS);
}
assertEquals("Background thread did not finish processing: msg count", msgCount, appender.getMessages().size());
// don't stop appender until background thread is done
appender.stop();
final List<String> list = appender.getMessages();
final String eventStr = list.get(0).toString();
Assert.assertTrue(eventStr, eventStr.contains(json));
}
use of org.apache.logging.log4j.core.Logger in project logging-log4j2 by apache.
the class CsvParameterLayoutAllAsyncTest method testLayoutTab.
@Test
public void testLayoutTab() throws Exception {
final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createLayout(CSVFormat.TDF), true);
}
use of org.apache.logging.log4j.core.Logger in project logging-log4j2 by apache.
the class CsvParameterLayoutAllAsyncTest method testLayoutDefaultObjectArrayMessage.
@Test
public void testLayoutDefaultObjectArrayMessage() throws Exception {
final Logger root = (Logger) LogManager.getRootLogger();
CsvParameterLayoutTest.testLayoutNormalApi(root, CsvParameterLayout.createDefaultLayout(), true);
}
use of org.apache.logging.log4j.core.Logger in project logging-log4j2 by apache.
the class AbstractFilterTest method verifyMethodsWithUnrolledVarargs.
private void verifyMethodsWithUnrolledVarargs(final ConcreteFilter filter, final Filter.Result expected) {
final Logger logger = null;
final Level level = null;
final Marker marker = null;
assertEquals(expected, filter.filter(logger, level, marker, "", 1));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7, 8));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7, 8, 9));
assertEquals(expected, filter.filter(logger, level, marker, "", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
}
Aggregations