Search in sources :

Example 1 with LoggerConfiguration

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);
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) Logger(java.util.logging.Logger) LogLevel(org.springframework.boot.logging.LogLevel)

Example 2 with LoggerConfiguration

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);
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) LogLevel(org.springframework.boot.logging.LogLevel)

Example 3 with LoggerConfiguration

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;
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) Configuration(org.apache.logging.log4j.core.config.Configuration) LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) ArrayList(java.util.ArrayList) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig)

Example 4 with LoggerConfiguration

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));
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration)

Example 5 with LoggerConfiguration

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);
}
Also used : LoggerConfiguration(org.springframework.boot.logging.LoggerConfiguration) LogLevel(org.springframework.boot.logging.LogLevel)

Aggregations

LoggerConfiguration (org.springframework.boot.logging.LoggerConfiguration)12 Test (org.junit.Test)6 LogLevel (org.springframework.boot.logging.LogLevel)4 LoggerLevels (org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels)2 Logger (ch.qos.logback.classic.Logger)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Logger (java.util.logging.Logger)1 Configuration (org.apache.logging.log4j.core.config.Configuration)1 LoggerConfig (org.apache.logging.log4j.core.config.LoggerConfig)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1