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);
}
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);
}
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;
}
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();
}
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);
}
Aggregations