use of org.apache.logging.log4j.core.config.LoggerConfig 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.LoggerConfig 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.LoggerConfig in project geode by apache.
the class Configurator method hasLoggerFilter.
public static boolean hasLoggerFilter(final Configuration config) {
for (LoggerConfig loggerConfig : config.getLoggers().values()) {
boolean isRoot = loggerConfig.getName().equals("");
boolean isGemFire = loggerConfig.getName().startsWith(LogService.BASE_LOGGER_NAME);
boolean hasFilter = loggerConfig.hasFilter();
boolean isGemFireVerboseFilter = hasFilter && (LogService.GEODE_VERBOSE_FILTER.equals(loggerConfig.getFilter().toString()) || LogService.GEMFIRE_VERBOSE_FILTER.equals(loggerConfig.getFilter().toString()));
if (isRoot || isGemFire) {
// check for Logger Filter
if (hasFilter && !isGemFireVerboseFilter) {
return true;
}
}
}
return false;
}
use of org.apache.logging.log4j.core.config.LoggerConfig 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;
}
use of org.apache.logging.log4j.core.config.LoggerConfig in project geode by apache.
the class Configurator method hasAppenderRefFilter.
public static boolean hasAppenderRefFilter(final Configuration config) {
for (LoggerConfig loggerConfig : config.getLoggers().values()) {
boolean isRoot = loggerConfig.getName().equals("");
boolean isGemFire = loggerConfig.getName().startsWith(LogService.BASE_LOGGER_NAME);
if (isRoot || isGemFire) {
// check for AppenderRef Filter
for (AppenderRef appenderRef : loggerConfig.getAppenderRefs()) {
if (appenderRef.getFilter() != null) {
return true;
}
}
}
}
return false;
}
Aggregations