Search in sources :

Example 31 with LoggerConfig

use of org.apache.logging.log4j.core.config.LoggerConfig in project pyramid by cheng-li.

the class RegressionSynthesizerTest method main.

public static void main(String[] args) throws Exception {
    LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
    Configuration config = ctx.getConfiguration();
    LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
    loggerConfig.setLevel(Level.DEBUG);
    ctx.updateLoggers();
//        test1();
}
Also used : Configuration(org.apache.logging.log4j.core.config.Configuration) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig)

Example 32 with LoggerConfig

use of org.apache.logging.log4j.core.config.LoggerConfig in project storm by apache.

the class LogConfigManager method getLoggerLevels.

public Map<String, Level> getLoggerLevels() {
    Configuration loggerConfig = ((LoggerContext) LogManager.getContext(false)).getConfiguration();
    Map<String, Level> logLevelMap = new HashMap<>();
    for (Map.Entry<String, LoggerConfig> entry : loggerConfig.getLoggers().entrySet()) {
        logLevelMap.put(entry.getKey(), entry.getValue().getLevel());
    }
    return logLevelMap;
}
Also used : Configuration(org.apache.logging.log4j.core.config.Configuration) HashMap(java.util.HashMap) LogLevel(org.apache.storm.generated.LogLevel) Level(org.apache.logging.log4j.Level) LoggerContext(org.apache.logging.log4j.core.LoggerContext) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig)

Example 33 with LoggerConfig

use of org.apache.logging.log4j.core.config.LoggerConfig in project hive by apache.

the class OperationManager method initOperationLogCapture.

private void initOperationLogCapture(String loggingMode) {
    // Register another Appender (with the same layout) that talks to us.
    Appender ap = LogDivertAppender.createInstance(this, OperationLog.getLoggingLevel(loggingMode));
    LoggerContext context = (LoggerContext) LogManager.getContext(false);
    Configuration configuration = context.getConfiguration();
    LoggerConfig loggerConfig = configuration.getLoggerConfig(LoggerFactory.getLogger(getClass()).getName());
    loggerConfig.addAppender(ap, null, null);
    context.updateLoggers();
    ap.start();
}
Also used : Appender(org.apache.logging.log4j.core.Appender) Configuration(org.apache.logging.log4j.core.config.Configuration) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig)

Example 34 with LoggerConfig

use of org.apache.logging.log4j.core.config.LoggerConfig in project hive by apache.

the class HiveEventCounter method removeFromLogger.

@VisibleForTesting
public void removeFromLogger(String loggerName) {
    LoggerConfig loggerConfig = configuration.getLoggerConfig(loggerName);
    loggerConfig.removeAppender(APPENDER_NAME);
    context.updateLoggers();
}
Also used : LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 35 with LoggerConfig

use of org.apache.logging.log4j.core.config.LoggerConfig in project hive by apache.

the class NullAppender method addToLogger.

public void addToLogger(String loggerName, Level level) {
    LoggerConfig loggerConfig = configuration.getLoggerConfig(loggerName);
    loggerConfig.addAppender(this, level, null);
    context.updateLoggers();
}
Also used : LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig)

Aggregations

LoggerConfig (org.apache.logging.log4j.core.config.LoggerConfig)63 Configuration (org.apache.logging.log4j.core.config.Configuration)38 LoggerContext (org.apache.logging.log4j.core.LoggerContext)32 Appender (org.apache.logging.log4j.core.Appender)11 Level (org.apache.logging.log4j.Level)9 Test (org.junit.Test)7 VisibleForTesting (com.google.common.annotations.VisibleForTesting)6 AppenderRef (org.apache.logging.log4j.core.config.AppenderRef)6 Logger (org.apache.logging.log4j.Logger)5 Filter (org.apache.logging.log4j.core.Filter)5 Configuration.getConfiguration (javax.security.auth.login.Configuration.getConfiguration)4 FileAppender (org.apache.logging.log4j.core.appender.FileAppender)4 ThresholdFilter (org.apache.logging.log4j.core.filter.ThresholdFilter)4 ConsoleAppender (org.apache.logging.log4j.core.appender.ConsoleAppender)3 PatternLayout (org.apache.logging.log4j.core.layout.PatternLayout)3 PropertyChangeListener (java.beans.PropertyChangeListener)2 File (java.io.File)2 Path (java.nio.file.Path)2 Map (java.util.Map)2 AppenderContext (org.apache.geode.internal.logging.log4j.AppenderContext)2