Shutdown logging in logging evil tests

The evil logging tests write to log files which are deleted at the end
of the test. If these files are not closed, some operating systems will
complain when these deletes are performed. This commit ensures that the
logging system is properly shutdown so that these files can be properly
deleted.
This commit is contained in:
Jason Tedor 2016-09-06 20:35:03 -04:00
parent a96f3d46b7
commit 98a278ed95
1 changed files with 10 additions and 0 deletions

View File

@ -20,7 +20,10 @@
package org.elasticsearch.common.logging; package org.elasticsearch.common.logging;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -59,6 +62,13 @@ public class EvilLoggerTests extends ESTestCase {
deprecationLogger = ESLoggerFactory.getDeprecationLogger("test"); deprecationLogger = ESLoggerFactory.getDeprecationLogger("test");
} }
@Override
public void tearDown() throws Exception {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configurator.shutdown(context);
super.tearDown();
}
public void testLocationInfoTest() throws IOException { public void testLocationInfoTest() throws IOException {
testLogger.error("This is an error message"); testLogger.error("This is an error message");
testLogger.warn("This is a warning message"); testLogger.warn("This is a warning message");