use of org.apache.logging.log4j.core.LoggerContext in project logging-log4j2 by apache.
the class XmlConfigurationPropsTest method testNoProps.
@Test
public void testNoProps() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
final LoggerContext ctx = LoggerContext.getContext();
ctx.reconfigure();
final Configuration config = ctx.getConfiguration();
assertTrue("Configuration is not an XmlConfiguration", config instanceof XmlConfiguration);
}
use of org.apache.logging.log4j.core.LoggerContext in project geode by apache.
the class Configurator method getLoggerConfig.
public static LoggerConfig getLoggerConfig(final String name) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration config = context.getConfiguration();
LoggerConfig logConfig = config.getLoggerConfig(name);
if (!logConfig.getName().equals(name)) {
throw new IllegalStateException("LoggerConfig does not exist for " + name);
}
return logConfig;
}
use of org.apache.logging.log4j.core.LoggerContext in project geode by apache.
the class Configurator method setLevel.
public static void setLevel(String name, Level level) {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
LoggerConfig logConfig = getLoggerConfig(name);
logConfig.setLevel(level);
context.updateLoggers();
if (level.isLessSpecificThan(Level.DEBUG)) {
LogService.configureFastLoggerDelegating();
}
}
use of org.apache.logging.log4j.core.LoggerContext in project spring-boot by spring-projects.
the class Log4J2LoggingSystem method loadConfiguration.
protected void loadConfiguration(String location, LogFile logFile) {
Assert.notNull(location, "Location must not be null");
try {
LoggerContext ctx = getLoggerContext();
URL url = ResourceUtils.getURL(location);
ConfigurationSource source = getConfigurationSource(url);
ctx.start(ConfigurationFactory.getInstance().getConfiguration(ctx, source));
} catch (Exception ex) {
throw new IllegalStateException("Could not initialize Log4J2 logging from " + location, ex);
}
}
use of org.apache.logging.log4j.core.LoggerContext in project spring-boot by spring-projects.
the class Log4J2LoggingSystem method cleanUp.
@Override
public void cleanUp() {
super.cleanUp();
LoggerContext loggerContext = getLoggerContext();
markAsUninitialized(loggerContext);
loggerContext.getConfiguration().removeFilter(FILTER);
}
Aggregations