use of org.jboss.logmanager.LogContext in project quarkus by quarkusio.
the class LogController method updateLogLevel.
public static void updateLogLevel(String loggerName, String levelValue) {
LogContext logContext = LogContext.getLogContext();
Logger logger = logContext.getLogger(loggerName);
java.util.logging.Level level;
if (levelValue == null || levelValue.isBlank()) {
if (logger.getParent() != null) {
level = logger.getParent().getLevel();
} else {
throw new IllegalArgumentException("The level of the root logger cannot be set to null");
}
} else {
level = Level.parse(levelValue);
}
logger.setLevel(level);
LOG.info("Log level updated [" + loggerName + "] changed to [" + levelValue + "]");
}
use of org.jboss.logmanager.LogContext in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class LoggingConfigWatcherTest method testConfigParsing.
@Test
public void testConfigParsing() throws MalformedURLException, IOException {
LoggingConfigWatcher.updateLoggingConfig(LoggingConfigWatcher.class.getResource("/loggingconfig/application.properties"));
LogContext logContext = LogContext.getLogContext();
org.jboss.logmanager.Logger logger = logContext.getLogger("some.category");
assertEquals(Level.DEBUG, logger.getLevel());
logger = logContext.getLogger("some.other.category");
assertEquals(Level.WARNING, logger.getLevel());
}
use of org.jboss.logmanager.LogContext in project activemq-artemis by rh-messaging.
the class LoggingConfigurationFileReloader method getOrCreateUpdater.
private LoggingConfigurationUpdater getOrCreateUpdater() {
final LogContext logContext = LogContext.getLogContext();
final org.jboss.logmanager.Logger rootLogger = logContext.getLogger("");
LoggingConfigurationUpdater updater = rootLogger.getAttachment(KEY);
if (updater == null) {
final LogContextConfiguration logContextConfiguration = getOrCreateConfiguration(rootLogger);
if (logContextConfiguration == null) {
return null;
}
updater = new LoggingConfigurationUpdater(logContextConfiguration);
final LoggingConfigurationUpdater appearing = rootLogger.attachIfAbsent(KEY, updater);
if (appearing != null) {
updater = appearing;
}
}
return updater;
}
Aggregations