Search in sources :

Example 1 with LogLevel

use of org.springframework.boot.logging.LogLevel 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 LogLevel

use of org.springframework.boot.logging.LogLevel 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 LogLevel

use of org.springframework.boot.logging.LogLevel in project spring-boot by spring-projects.

the class LoggersMvcEndpoint method set.

@ActuatorPostMapping("/{name:.*}")
@ResponseBody
@HypermediaDisabled
public Object set(@PathVariable String name, @RequestBody Map<String, String> configuration) {
    if (!this.delegate.isEnabled()) {
        // disabled
        return getDisabledResponse();
    }
    String level = configuration.get("configuredLevel");
    LogLevel logLevel = level == null ? null : LogLevel.valueOf(level.toUpperCase());
    this.delegate.setLogLevel(name, logLevel);
    return HttpEntity.EMPTY;
}
Also used : LogLevel(org.springframework.boot.logging.LogLevel) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with LogLevel

use of org.springframework.boot.logging.LogLevel in project spring-boot by spring-projects.

the class Log4J2LoggingSystem method setLogLevel.

@Override
public void setLogLevel(String loggerName, LogLevel logLevel) {
    Level level = LEVELS.convertSystemToNative(logLevel);
    LoggerConfig loggerConfig = getLoggerConfig(loggerName);
    if (loggerConfig == null) {
        loggerConfig = new LoggerConfig(loggerName, level, true);
        getLoggerContext().getConfiguration().addLogger(loggerName, loggerConfig);
    } else {
        loggerConfig.setLevel(level);
    }
    getLoggerContext().updateLoggers();
}
Also used : Level(org.apache.logging.log4j.Level) LogLevel(org.springframework.boot.logging.LogLevel) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig)

Example 5 with LogLevel

use of org.springframework.boot.logging.LogLevel 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

LogLevel (org.springframework.boot.logging.LogLevel)7 LoggerConfiguration (org.springframework.boot.logging.LoggerConfiguration)4 EnumSet (java.util.EnumSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Logger (java.util.logging.Logger)1 Level (org.apache.logging.log4j.Level)1 LoggerConfig (org.apache.logging.log4j.core.config.LoggerConfig)1 Test (org.junit.Test)1 LoggerLevels (org.springframework.boot.actuate.endpoint.LoggersEndpoint.LoggerLevels)1 ManagedOperation (org.springframework.jmx.export.annotation.ManagedOperation)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1