use of org.apache.geode.internal.logging.log4j.AppenderContext in project geode by apache.
the class LogService method removeConsoleAppender.
/**
* Removes STDOUT ConsoleAppender from ROOT logger. Only called when using the log4j2-default.xml
* configuration. This is done when creating the LogWriterAppender for log-file. The Appender
* instance is stored in stdoutAppender so it can be restored later using restoreConsoleAppender.
*/
public static synchronized void removeConsoleAppender() {
final AppenderContext appenderContext = LogService.getAppenderContext(LogService.ROOT_LOGGER_NAME);
final LoggerConfig config = appenderContext.getLoggerConfig();
Appender stdout = config.getAppenders().get(STDOUT);
if (stdout != null) {
config.removeAppender(STDOUT);
stdoutAppender = stdout;
appenderContext.getLoggerContext().updateLoggers();
}
}
use of org.apache.geode.internal.logging.log4j.AppenderContext in project geode by apache.
the class LogService method restoreConsoleAppender.
/**
* Restores STDOUT ConsoleAppender to ROOT logger. Only called when using the log4j2-default.xml
* configuration. This is done when the LogWriterAppender for log-file is destroyed. The Appender
* instance stored in stdoutAppender is used.
*/
public static synchronized void restoreConsoleAppender() {
if (stdoutAppender == null) {
return;
}
final AppenderContext appenderContext = LogService.getAppenderContext(LogService.ROOT_LOGGER_NAME);
final LoggerConfig config = appenderContext.getLoggerConfig();
Appender stdout = config.getAppenders().get(STDOUT);
if (stdout == null) {
config.addAppender(stdoutAppender, Level.ALL, null);
appenderContext.getLoggerContext().updateLoggers();
}
}
use of org.apache.geode.internal.logging.log4j.AppenderContext in project geode by apache.
the class LogServiceJUnitTest method getAppenderContextWithNameShouldHaveName.
@Test
public void getAppenderContextWithNameShouldHaveName() throws Exception {
final String name = "someName";
final AppenderContext appenderContext = LogService.getAppenderContext(name);
assertThat(appenderContext.getName()).isEqualTo(name);
}
use of org.apache.geode.internal.logging.log4j.AppenderContext in project geode by apache.
the class LogServiceJUnitTest method getAppenderContextShouldHaveEmptyName.
@Test
public void getAppenderContextShouldHaveEmptyName() throws Exception {
final AppenderContext appenderContext = LogService.getAppenderContext();
assertThat(appenderContext.getName()).isEmpty();
}
Aggregations