use of org.apache.karaf.log.core.Level in project karaf by apache.
the class LogServiceImpl method setLevel.
public void setLevel(String logger, String level) {
// make sure both uppercase and lowercase levels are supported
level = level.toUpperCase();
// check if the level is valid
Level lvl = Level.valueOf(level);
// Default logger
if (logger == null) {
logger = LogServiceInternal.ROOT_LOGGER;
}
// Verify
if (lvl == Level.DEFAULT && LogServiceInternal.ROOT_LOGGER.equals(logger)) {
throw new IllegalStateException("Can not unset the ROOT logger");
}
// Get config
Configuration cfg = getConfiguration();
Dictionary<String, Object> props = cfg.getProperties();
// Update
getDelegate(props).setLevel(logger, level);
// Save
try {
cfg.update(props);
} catch (IOException e) {
throw new RuntimeException("Error writing log config to config admin", e);
}
}
Aggregations