use of org.springframework.boot.logging.LoggerConfiguration in project spring-boot by spring-projects.
the class JavaLoggingSystem method getLoggerConfiguration.
@Override
public LoggerConfiguration getLoggerConfiguration(String loggerName) {
Logger logger = Logger.getLogger(loggerName);
if (logger == null) {
return null;
}
LogLevel level = LEVELS.convertNativeToSystem(logger.getLevel());
LogLevel effectiveLevel = LEVELS.convertNativeToSystem(getEffectiveLevel(logger));
String name = (StringUtils.hasLength(logger.getName()) ? logger.getName() : ROOT_LOGGER_NAME);
return new LoggerConfiguration(name, level, effectiveLevel);
}
use of org.springframework.boot.logging.LoggerConfiguration in project spring-boot by spring-projects.
the class Log4J2LoggingSystem method convertLoggerConfiguration.
private LoggerConfiguration convertLoggerConfiguration(LoggerConfig loggerConfig) {
if (loggerConfig == null) {
return null;
}
LogLevel level = LEVELS.convertNativeToSystem(loggerConfig.getLevel());
String name = loggerConfig.getName();
if (!StringUtils.hasLength(name) || LogManager.ROOT_LOGGER_NAME.equals(name)) {
name = ROOT_LOGGER_NAME;
}
return new LoggerConfiguration(name, level, level);
}
use of org.springframework.boot.logging.LoggerConfiguration in project spring-boot by spring-projects.
the class Log4J2LoggingSystem method getLoggerConfigurations.
@Override
public List<LoggerConfiguration> getLoggerConfigurations() {
List<LoggerConfiguration> result = new ArrayList<>();
Configuration configuration = getLoggerContext().getConfiguration();
for (LoggerConfig loggerConfig : configuration.getLoggers().values()) {
result.add(convertLoggerConfiguration(loggerConfig));
}
Collections.sort(result, CONFIGURATION_COMPARATOR);
return result;
}
use of org.springframework.boot.logging.LoggerConfiguration in project spring-boot by spring-projects.
the class LoggersEndpoint method invoke.
public LoggerLevels invoke(String name) {
Assert.notNull(name, "Name must not be null");
LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration(name);
return (configuration == null ? null : new LoggerLevels(configuration));
}
use of org.springframework.boot.logging.LoggerConfiguration in project spring-boot by spring-projects.
the class LogbackLoggingSystem method getLoggerConfiguration.
private LoggerConfiguration getLoggerConfiguration(ch.qos.logback.classic.Logger logger) {
if (logger == null) {
return null;
}
LogLevel level = LEVELS.convertNativeToSystem(logger.getLevel());
LogLevel effectiveLevel = LEVELS.convertNativeToSystem(logger.getEffectiveLevel());
String name = logger.getName();
if (!StringUtils.hasLength(name) || Logger.ROOT_LOGGER_NAME.equals(name)) {
name = ROOT_LOGGER_NAME;
}
return new LoggerConfiguration(name, level, effectiveLevel);
}
Aggregations