From 127255f62e6548f82777dd442ae27cac2f8bf03d Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 9 Dec 2014 23:31:24 +0100 Subject: [PATCH] [TEST] Restore test logging level after test is done --- .../common/logging/log4j/Log4jESLoggerTests.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java b/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java index 47b4020f06c..f1653489881 100644 --- a/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java +++ b/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.After; import org.junit.Test; import java.net.URL; @@ -43,10 +44,12 @@ public class Log4jESLoggerTests extends ElasticsearchTestCase { private ESLogger esTestLogger; private TestAppender testAppender; + private String testLevel; @Override public void setUp() throws Exception { super.setUp(); + this.testLevel = Log4jESLoggerFactory.getLogger("test").getLevel(); LogConfigurator.reset(); Path configDir = resolveConfigDir(); // Need to set custom path.conf so we can use a custom logging.yml file for the test @@ -62,6 +65,14 @@ public class Log4jESLoggerTests extends ElasticsearchTestCase { testLogger.addAppender(testAppender); } + @After + public void tearDown() throws Exception { + super.tearDown(); + esTestLogger.setLevel(testLevel); + Logger testLogger = ((Log4jESLogger) esTestLogger).logger(); + testLogger.removeAppender(testAppender); + } + @Test public void locationInfoTest() { esTestLogger.error("This is an error");