Map log-level 'trace' to JDK-Level 'FINEST' to make it possible to actually enable the trace-log via JdkESLogger.setLevel()

This commit is contained in:
Dominik Stadler 2015-10-21 21:05:51 +02:00 committed by Daniel Mitterdorfer
parent 48771f1a76
commit 72cab4e9b6
2 changed files with 15 additions and 1 deletions

View File

@ -50,7 +50,7 @@ public class JdkESLogger extends AbstractESLogger {
} else if ("debug".equalsIgnoreCase(level)) {
logger.setLevel(Level.FINE);
} else if ("trace".equalsIgnoreCase(level)) {
logger.setLevel(Level.FINE);
logger.setLevel(Level.FINEST);
}
}

View File

@ -91,6 +91,20 @@ public class JDKESLoggerTests extends ESTestCase {
assertThat(record.getSourceMethodName(), equalTo("testLocationInfoTest"));
}
public void testSetLogLevelString() {
// verify the string based level-setters
esTestLogger.setLevel("error");
assertThat(esTestLogger.getLevel(), equalTo("SEVERE"));
esTestLogger.setLevel("warn");
assertThat(esTestLogger.getLevel(), equalTo("WARNING"));
esTestLogger.setLevel("info");
assertThat(esTestLogger.getLevel(), equalTo("INFO"));
esTestLogger.setLevel("debug");
assertThat(esTestLogger.getLevel(), equalTo("FINE"));
esTestLogger.setLevel("trace");
assertThat(esTestLogger.getLevel(), equalTo("FINEST"));
}
private static class TestHandler extends Handler {
private List<LogRecord> records = new ArrayList<>();