@Test
public void testLog4jAppender() throws IOException {

  configureSource();
  PropertyConfigurator.configure(props);
  Logger logger = LogManager.getLogger(TestLog4jAppender.class);
  for (int count = 0; count <= 1000; count++) {
    /*
     * Log4j internally defines levels as multiples of 10000. So if we
     * create levels directly using count, the level will be set as the
     * default.
     */
    int level = ((count % 5) + 1) * 10000;
    String msg = "This is log message number" + String.valueOf(count);
    logger.log(Level.toLevel(level), msg);
    Transaction transaction = ch.getTransaction();
    transaction.begin();
    Event event = ch.take();
    Assert.assertNotNull(event);
    Assert.assertEquals(new String(event.getBody(), "UTF8"), msg);
    Map<String, String> hdrs = event.getHeaders();
    Assert.assertNotNull(hdrs.get(Log4jAvroHeaders.TIMESTAMP.toString()));
    Assert.assertEquals(Level.toLevel(level),
        Level.toLevel(Integer.valueOf(hdrs.get(Log4jAvroHeaders.LOG_LEVEL
            .toString()))
        ));
    Assert.assertNotNull(hdrs.get(Log4jAvroHeaders.ADDRESS.toString()));
    Assert.assertEquals(logger.getName(),
        hdrs.get(Log4jAvroHeaders.LOGGER_NAME.toString()));
    Assert.assertEquals("UTF8",
        hdrs.get(Log4jAvroHeaders.MESSAGE_ENCODING.toString()));
    transaction.commit();
    transaction.close();
  }
}