Avoid double logging config init + support for slf4j-log4j.
This commit is contained in:
@@ -42,7 +42,6 @@ public abstract class AbstractLoggingSystem extends LoggingSystem {
|
||||
|
||||
@Override
|
||||
public void beforeInitialize() {
|
||||
initializeWithSensibleDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,10 +23,12 @@ import java.util.Map;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
import org.springframework.boot.logging.AbstractLoggingSystem;
|
||||
import org.springframework.boot.logging.LogLevel;
|
||||
import org.springframework.boot.logging.LoggingSystem;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.Log4jConfigurer;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -54,6 +56,15 @@ public class Log4JLoggingSystem extends AbstractLoggingSystem {
|
||||
super(classLoader, "log4j.xml", "log4j.properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeInitialize() {
|
||||
super.beforeInitialize();
|
||||
if (ClassUtils.isPresent("org.slf4j.bridge.SLF4JBridgeHandler", getClassLoader())) {
|
||||
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
||||
SLF4JBridgeHandler.install();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(String configLocation) {
|
||||
Assert.notNull(configLocation, "ConfigLocation must not be null");
|
||||
|
||||
Reference in New Issue
Block a user