[TEST] Restore test logging level after test is done
This commit is contained in:
parent
796ebcb88b
commit
127255f62e
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue