Start mock appender for capturing logger

The base test case class has been adapted to assert that no warn nor
error messages are logged to the Log4j status logger. An issue that
exists in x-pack uncovered by this change is that the mock appender in
the capturing logger was never started. This commit addresses this
issue.

Relates elastic/elasticsearch#3988

Original commit: elastic/x-pack-elasticsearch@8fc0b99bae
This commit is contained in:
Jason Tedor 2016-11-04 14:21:28 -04:00 committed by GitHub
parent ae960f976d
commit 4e0457276d
1 changed files with 3 additions and 1 deletions

View File

@ -27,7 +27,9 @@ public class CapturingLogger {
final String name = caller.getClassName() + "." + caller.getMethodName() + "." + level.toString();
final Logger logger = ESLoggerFactory.getLogger(name);
Loggers.setLevel(logger, level);
Loggers.addAppender(logger, new MockAppender(name));
final MockAppender appender = new MockAppender(name);
appender.start();
Loggers.addAppender(logger, appender);
return logger;
}