use of org.apache.logging.log4j.core.LoggerContext in project ignite by apache.
the class Log4J2Logger method setLevel.
/**
* Sets level for internal log4j implementation.
*
* @param level Log level to set.
*/
public void setLevel(Level level) {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration conf = ctx.getConfiguration();
conf.getLoggerConfig(impl.getName()).setLevel(level);
ctx.updateLoggers(conf);
}
use of org.apache.logging.log4j.core.LoggerContext in project geode by apache.
the class GfshInitFileJUnitTest method tearDownAfterClass.
/*
* Restore logging to state prior to the execution of this class
*/
@AfterClass
public static void tearDownAfterClass() throws Exception {
for (Handler handler : saveHandlers) {
julLogger.addHandler(handler);
}
if (saveLog4j2Config == null) {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
} else {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, saveLog4j2Config);
((LoggerContext) LogManager.getContext(false)).reconfigure();
}
}
use of org.apache.logging.log4j.core.LoggerContext in project geode by apache.
the class DUnitLauncher method addSuspectFileAppender.
/**
* Add an appender to Log4j which sends all INFO+ messages to a separate file which will be used
* later to scan for suspect strings. The pattern of the messages conforms to the original log
* format so that hydra will be able to parse them.
*/
private static void addSuspectFileAppender(final String workspaceDir) {
final String suspectFilename = new File(workspaceDir, SUSPECT_FILENAME).getAbsolutePath();
final LoggerContext appenderContext = ((org.apache.logging.log4j.core.Logger) LogManager.getLogger(LogService.BASE_LOGGER_NAME)).getContext();
final PatternLayout layout = PatternLayout.createLayout("[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} <%thread> tid=%tid] %message%n%throwable%n", null, null, null, Charset.defaultCharset(), true, false, "", "");
final FileAppender fileAppender = FileAppender.createAppender(suspectFilename, "true", "false", DUnitLauncher.class.getName(), "true", "false", "false", "0", layout, null, null, null, appenderContext.getConfiguration());
fileAppender.start();
LoggerConfig loggerConfig = appenderContext.getConfiguration().getLoggerConfig(LogService.BASE_LOGGER_NAME);
loggerConfig.addAppender(fileAppender, Level.INFO, null);
}
use of org.apache.logging.log4j.core.LoggerContext in project geode by apache.
the class DistributedSystemLogFileJUnitTest method tearDown.
@After
public void tearDown() throws Exception {
if (this.system != null) {
this.system.disconnect();
this.system = null;
}
// We will want to remove this at some point but right now the log context
// does not clear out the security logconfig between tests
LoggerContext context = (LoggerContext) LogManager.getContext(false);
context.stop();
}
use of org.apache.logging.log4j.core.LoggerContext 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();
}
Aggregations