appender.setThreshold(Level.INFO);
appender.setSyslogHost("localhost");
appender.setFacility("user");
appender.setLayout(new PatternLayout("%m%n"));
VectorErrorHandler errorHandler = new VectorErrorHandler();
appender.setErrorHandler(errorHandler);
appender.activateOptions();
//
// wrap SyslogAppender with an Async since appender may
// hang if syslogd is not accepting network messages
//
AsyncAppender asyncAppender = new AsyncAppender();
asyncAppender.addAppender(appender);
asyncAppender.activateOptions();
Logger logger = Logger.getRootLogger();
logger.addAppender(asyncAppender);
Exception e =
new Exception("Expected exception from SyslogAppenderTest.testAppend");
logger.info(
"Expected message from log4j unit test SyslogAppenderTest.testAppend.", e);
assertEquals(0, errorHandler.size());
}