Search in sources :

Example 11 with Logger

use of org.jboss.logmanager.Logger 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 + "]");
}
Also used : LogContext(org.jboss.logmanager.LogContext) Logger(org.jboss.logmanager.Logger) Level(java.util.logging.Level)

Aggregations

Logger (org.jboss.logmanager.Logger)11 LogContext (org.jboss.logmanager.LogContext)6 Path (java.nio.file.Path)3 Handler (java.util.logging.Handler)3 Level (java.util.logging.Level)3 ModelNode (org.jboss.dmr.ModelNode)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ErrorManager (java.util.logging.ErrorManager)2 LoggingLogger (org.jboss.as.logging.logging.LoggingLogger)2 Configurator (org.jboss.logmanager.Configurator)2 PropertyConfigurator (org.jboss.logmanager.PropertyConfigurator)2 OnlyOnceErrorManager (org.jboss.logmanager.errormanager.OnlyOnceErrorManager)2 AsyncHandler (org.jboss.logmanager.handlers.AsyncHandler)2 ConsoleHandler (org.jboss.logmanager.handlers.ConsoleHandler)2 FileHandler (org.jboss.logmanager.handlers.FileHandler)2 PeriodicSizeRotatingFileHandler (org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler)2 SizeRotatingFileHandler (org.jboss.logmanager.handlers.SizeRotatingFileHandler)2 SyslogHandler (org.jboss.logmanager.handlers.SyslogHandler)2