Make Log4J logging system consistent with the others
when the logname is empty it replaces it with the root logger name. Fixes gh-4808
This commit is contained in:
parent
ecf56f0708
commit
d493d3afe7
|
|
@ -111,7 +111,8 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
|
|||
@Override
|
||||
public void setLogLevel(String loggerName, LogLevel level) {
|
||||
Assert.notNull(level, "Level must not be null");
|
||||
Logger logger = Logger.getLogger(loggerName == null ? "" : loggerName);
|
||||
Logger logger = Logger
|
||||
.getLogger(StringUtils.hasText(loggerName) ? loggerName : "");
|
||||
logger.setLevel(LEVELS.get(level));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import org.springframework.boot.logging.Slf4JLoggingSystem;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link LoggingSystem} for <a href="http://logging.apache.org/log4j/2.x/">Log4j 2</a>.
|
||||
|
|
@ -208,6 +209,8 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem {
|
|||
}
|
||||
|
||||
private LoggerConfig getLoggerConfig(String loggerName) {
|
||||
loggerName = StringUtils.hasText(loggerName) ? loggerName
|
||||
: LogManager.ROOT_LOGGER_NAME;
|
||||
return getLoggerContext().getConfiguration().getLoggers().get(loggerName);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue