Merge branch '1.5.x'

This commit is contained in:
Madhura Bhave
2017-03-17 16:19:02 -07:00
3 changed files with 28 additions and 2 deletions

View File

@@ -199,7 +199,9 @@ public abstract class AbstractLoggingSystem extends LoggingSystem {
}
public void map(LogLevel system, T nativeLevel) {
this.systemToNative.put(system, nativeLevel);
if (!this.systemToNative.containsKey(system)) {
this.systemToNative.put(system, nativeLevel);
}
if (!this.nativeToSystem.containsKey(nativeLevel)) {
this.nativeToSystem.put(nativeLevel, system);
}

View File

@@ -64,6 +64,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
static {
LEVELS.map(LogLevel.TRACE, Level.TRACE);
LEVELS.map(LogLevel.TRACE, Level.ALL);
LEVELS.map(LogLevel.DEBUG, Level.DEBUG);
LEVELS.map(LogLevel.INFO, Level.INFO);
LEVELS.map(LogLevel.WARN, Level.WARN);
@@ -259,7 +260,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
return new ShutdownHandler();
}
private ch.qos.logback.classic.Logger getLogger(String name) {
ch.qos.logback.classic.Logger getLogger(String name) {
LoggerContext factory = getLoggerContext();
if (StringUtils.isEmpty(name) || ROOT_LOGGER_NAME.equals(name)) {
name = Logger.ROOT_LOGGER_NAME;

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.logging.Handler;
import java.util.logging.LogManager;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.LoggerContextListener;
@@ -64,6 +65,7 @@ import static org.mockito.Mockito.verify;
* @author Phillip Webb
* @author Andy Wilkinson
* @author Ben Hale
* @author Madhura Bhave
*/
public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
@@ -205,6 +207,27 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
LogLevel.DEBUG, LogLevel.DEBUG));
}
@Test
public void getLoggingConfigurationForALL() throws Exception {
this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null);
Logger logger = this.loggingSystem.getLogger(getClass().getName());
logger.setLevel(Level.ALL);
LoggerConfiguration configuration = this.loggingSystem
.getLoggerConfiguration(getClass().getName());
assertThat(configuration).isEqualTo(new LoggerConfiguration(getClass().getName(),
LogLevel.TRACE, LogLevel.TRACE));
}
@Test
public void systemLevelTraceShouldReturnNativeLevelTraceNotAll() throws Exception {
this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null);
this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.TRACE);
Logger logger = this.loggingSystem.getLogger(getClass().getName());
assertThat(logger.getLevel()).isEqualTo(Level.TRACE);
}
@Test
public void loggingThatUsesJulIsCaptured() {
this.loggingSystem.beforeInitialize();