use of org.apache.logging.log4j.core.config.Configuration in project graylog2-server by Graylog2.
the class LoggersResource method getAppender.
private Appender getAppender(final String appenderName) {
final LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
final Configuration configuration = loggerContext.getConfiguration();
return configuration.getAppender(appenderName);
}
use of org.apache.logging.log4j.core.config.Configuration in project torodb by torodb.
the class Log4jUtils method setRootLevel.
public static void setRootLevel(LogLevel logLevel) {
LoggerContext coreContext = (LoggerContext) LogManager.getContext(false);
Configuration configuration = coreContext.getConfiguration();
for (LoggerConfig loggerConfig : configuration.getLoggers().values()) {
setLevel(loggerConfig, logLevel);
}
}
use of org.apache.logging.log4j.core.config.Configuration in project jabref by JabRef.
the class JabRefLogger method setLogLevelToDebugForJabRefClasses.
private static void setLogLevelToDebugForJabRefClasses() {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig("org.jabref");
loggerConfig.setLevel(Level.DEBUG);
ctx.updateLoggers();
}
use of org.apache.logging.log4j.core.config.Configuration in project geode by apache.
the class Configurator method getOrCreateLoggerConfig.
public static LoggerConfig getOrCreateLoggerConfig(String name, boolean additive, boolean forceAdditivity) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration config = context.getConfiguration();
LoggerConfig logConfig = config.getLoggerConfig(name);
boolean update = false;
if (!logConfig.getName().equals(name)) {
List<AppenderRef> appenderRefs = logConfig.getAppenderRefs();
Map<Property, Boolean> properties = logConfig.getProperties();
Set<Property> props = properties == null ? null : properties.keySet();
logConfig = LoggerConfig.createLogger(String.valueOf(additive), logConfig.getLevel(), name, String.valueOf(logConfig.isIncludeLocation()), appenderRefs == null ? null : appenderRefs.toArray(new AppenderRef[appenderRefs.size()]), props == null ? null : props.toArray(new Property[props.size()]), config, null);
config.addLogger(name, logConfig);
update = true;
}
if (forceAdditivity && logConfig.isAdditive() != additive) {
logConfig.setAdditive(additive);
update = true;
}
if (update) {
context.updateLoggers();
}
return logConfig;
}
use of org.apache.logging.log4j.core.config.Configuration in project geode by apache.
the class Configurator method getOrCreateLoggerConfig.
public static LoggerConfig getOrCreateLoggerConfig(String name) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration config = context.getConfiguration();
LoggerConfig logConfig = config.getLoggerConfig(name);
boolean update = false;
if (!logConfig.getName().equals(name)) {
List<AppenderRef> appenderRefs = logConfig.getAppenderRefs();
Map<Property, Boolean> properties = logConfig.getProperties();
Set<Property> props = properties == null ? null : properties.keySet();
logConfig = LoggerConfig.createLogger(String.valueOf(logConfig.isAdditive()), logConfig.getLevel(), name, String.valueOf(logConfig.isIncludeLocation()), appenderRefs == null ? null : appenderRefs.toArray(new AppenderRef[appenderRefs.size()]), props == null ? null : props.toArray(new Property[props.size()]), config, null);
config.addLogger(name, logConfig);
update = true;
}
if (update) {
context.updateLoggers();
}
return logConfig;
}
Aggregations