use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class RoutesScriptAppenderTest method logAndCheck.
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(RoutesScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
assertEquals("Incorrect number of events", 1, listAppender.getEvents().size());
logger.error("World");
assertEquals("Incorrect number of events", 2, listAppender.getEvents().size());
logger.error(marker, "DEADBEEF");
assertEquals("Incorrect number of events", 3, listAppender.getEvents().size());
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class ScriptArbiterTest method prodTest.
@Test
public void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
assertTrue(app instanceof ListAppender);
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class ScriptAppenderSelectorTest method verify.
static void verify(final Configuration config) {
assertNull(config.getAppender("List1"), "List1 appender should not be initialized");
assertNull(config.getAppender("List2"), "List2 appender should not be initialized");
final ListAppender listAppender = config.getAppender("SelectIt");
assertNotNull(listAppender);
final ExtendedLogger logger = config.getLoggerContext().getLogger(ScriptAppenderSelectorTest.class);
logger.error("Hello");
assertThat(listAppender.getEvents(), hasSize(1));
logger.error("World");
assertThat(listAppender.getEvents(), hasSize(2));
logger.error(MarkerManager.getMarker("HEXDUMP"), "DEADBEEF");
assertThat(listAppender.getEvents(), hasSize(3));
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class DefaultRouteScriptAppenderTest method logAndCheck.
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(DefaultRouteScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
assertEquals("Incorrect number of events", 1, listAppender.getEvents().size());
logger.error("World");
assertEquals("Incorrect number of events", 2, listAppender.getEvents().size());
logger.error(marker, "DEADBEEF");
assertEquals("Incorrect number of events", 3, listAppender.getEvents().size());
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class CallerInformationTest method testClassLogger.
@Test
public void testClassLogger() throws Exception {
final ListAppender app = ctx.getListAppender("Class").clear();
final Logger logger = LoggerFactory.getLogger("ClassLogger");
logger.info("Ignored message contents.");
logger.warn("Verifying the caller class is still correct.");
logger.error("Hopefully nobody breaks me!");
final List<String> messages = app.getMessages();
assertEquals("Incorrect number of messages.", 3, messages.size());
for (final String message : messages) {
assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
}
}
Aggregations