|  | @@ -21,15 +21,16 @@ package org.elasticsearch.common.logging;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import org.apache.logging.log4j.Level;
 | 
	
		
			
				|  |  |  import org.apache.logging.log4j.Logger;
 | 
	
		
			
				|  |  | +import org.elasticsearch.Version;
 | 
	
		
			
				|  |  |  import org.elasticsearch.common.io.PathUtils;
 | 
	
		
			
				|  |  |  import org.elasticsearch.common.settings.Settings;
 | 
	
		
			
				|  |  |  import org.elasticsearch.env.Environment;
 | 
	
		
			
				|  |  |  import org.elasticsearch.test.ESTestCase;
 | 
	
		
			
				|  |  | +import org.elasticsearch.test.hamcrest.RegexMatcher;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.nio.file.Files;
 | 
	
		
			
				|  |  |  import java.nio.file.Path;
 | 
	
		
			
				|  |  | -import java.nio.file.Paths;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.regex.Matcher;
 | 
	
		
			
				|  |  |  import java.util.regex.Pattern;
 | 
	
	
		
			
				|  | @@ -66,21 +67,22 @@ public class EvilLoggerTests extends ESTestCase {
 | 
	
		
			
				|  |  |          testLogger.trace("This is a trace message");
 | 
	
		
			
				|  |  |          final String path = System.getProperty("es.logs") + ".log";
 | 
	
		
			
				|  |  |          final List<String> events = Files.readAllLines(PathUtils.get(path));
 | 
	
		
			
				|  |  | -        assertThat(events.size(), equalTo(5));
 | 
	
		
			
				|  |  | +        assertThat(events.size(), equalTo(6)); // the five messages me log plus a warning for unsupported configuration files
 | 
	
		
			
				|  |  |          final String location = "org.elasticsearch.common.logging.EvilLoggerTests.testLocationInfoTest";
 | 
	
		
			
				|  |  | -        assertLogLine(events.get(0), Level.ERROR, location, "This is an error message");
 | 
	
		
			
				|  |  | -        assertLogLine(events.get(1), Level.WARN, location, "This is a warning message");
 | 
	
		
			
				|  |  | -        assertLogLine(events.get(2), Level.INFO, location, "This is an info message");
 | 
	
		
			
				|  |  | -        assertLogLine(events.get(3), Level.DEBUG, location, "This is a debug message");
 | 
	
		
			
				|  |  | -        assertLogLine(events.get(4), Level.TRACE, location, "This is a trace message");
 | 
	
		
			
				|  |  | +        // the first message is a warning for unsupported configuration files
 | 
	
		
			
				|  |  | +        assertLogLine(events.get(1), Level.ERROR, location, "This is an error message");
 | 
	
		
			
				|  |  | +        assertLogLine(events.get(2), Level.WARN, location, "This is a warning message");
 | 
	
		
			
				|  |  | +        assertLogLine(events.get(3), Level.INFO, location, "This is an info message");
 | 
	
		
			
				|  |  | +        assertLogLine(events.get(4), Level.DEBUG, location, "This is a debug message");
 | 
	
		
			
				|  |  | +        assertLogLine(events.get(5), Level.TRACE, location, "This is a trace message");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void assertLogLine(final String logLine, final Level level, final String location, final String message) {
 | 
	
		
			
				|  |  |          final Matcher matcher = Pattern.compile("\\[(.*)\\]\\[(.*)\\(.*\\)\\] (.*)").matcher(logLine);
 | 
	
		
			
				|  |  |          assertTrue(logLine, matcher.matches());
 | 
	
		
			
				|  |  |          assertThat(matcher.group(1), equalTo(level.toString()));
 | 
	
		
			
				|  |  | -        assertThat(matcher.group(2), equalTo(location));
 | 
	
		
			
				|  |  | -        assertThat(matcher.group(3), equalTo(message));
 | 
	
		
			
				|  |  | +        assertThat(matcher.group(2), RegexMatcher.matches(location));
 | 
	
		
			
				|  |  | +        assertThat(matcher.group(3), RegexMatcher.matches(message));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public void testDeprecationLogger() throws IOException {
 | 
	
	
		
			
				|  | @@ -95,4 +97,17 @@ public class EvilLoggerTests extends ESTestCase {
 | 
	
		
			
				|  |  |              "This is a deprecation message");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public void testUnsupportedLoggingConfigurationFiles() throws IOException {
 | 
	
		
			
				|  |  | +        // TODO: the warning for unsupported logging configurations can be removed in 6.0.0
 | 
	
		
			
				|  |  | +        assert Version.CURRENT.major < 6;
 | 
	
		
			
				|  |  | +        final String path = System.getProperty("es.logs") + ".log";
 | 
	
		
			
				|  |  | +        final List<String> events = Files.readAllLines(PathUtils.get(path));
 | 
	
		
			
				|  |  | +        assertThat(events.size(), equalTo(1));
 | 
	
		
			
				|  |  | +        assertLogLine(
 | 
	
		
			
				|  |  | +            events.get(0),
 | 
	
		
			
				|  |  | +            Level.WARN,
 | 
	
		
			
				|  |  | +            "org\\.elasticsearch\\.common\\.logging\\.LogConfigurator.*",
 | 
	
		
			
				|  |  | +            "ignoring unsupported logging configuration file \\[.*\\], logging is configured via \\[.*\\]");
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |