use of org.apache.logging.log4j.core.Logger in project torodb by torodb.
the class Log4jUtils method addRootAppenderListener.
public static void addRootAppenderListener(AppenderListener appenderListener) {
org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getRootLogger();
org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) logger;
InternalAppenderListener internalAppenderListener = new InternalAppenderListener(appenderListener);
internalAppenderListener.start();
coreLogger.addAppender(internalAppenderListener);
}
use of org.apache.logging.log4j.core.Logger in project geode by apache.
the class AppenderContext method getLoggerConfig.
public LoggerConfig getLoggerConfig() {
final Logger logger = getLogger();
final LoggerContext context = logger.getContext();
return context.getConfiguration().getLoggerConfig(logger.getName());
}
use of org.apache.logging.log4j.core.Logger in project geode by apache.
the class LogServiceIntegrationJUnitTest method removeConsoleAppenderShouldRemoveStdout.
@Test
public void removeConsoleAppenderShouldRemoveStdout() {
LogService.reconfigure();
final Logger rootLogger = (Logger) LogService.getRootLogger();
LogService.removeConsoleAppender();
assertThat(rootLogger.getAppenders().get(LogService.STDOUT)).isNull();
}
use of org.apache.logging.log4j.core.Logger in project geode by apache.
the class LogServiceIntegrationJUnitTest method restoreConsoleAppenderShouldRestoreStdout.
@Test
public void restoreConsoleAppenderShouldRestoreStdout() {
LogService.reconfigure();
final Logger rootLogger = (Logger) LogService.getRootLogger();
LogService.removeConsoleAppender();
assertThat(rootLogger.getAppenders().get(LogService.STDOUT)).isNull();
LogService.restoreConsoleAppender();
assertThat(rootLogger.getAppenders().get(LogService.STDOUT)).isNotNull();
}
use of org.apache.logging.log4j.core.Logger in project ignite by apache.
the class Log4J2Logger method addConsoleAppenderIfNeeded.
/**
* Adds console appender when needed with some default logging settings.
*
* @param initLogClo Optional log implementation init closure.
*/
private void addConsoleAppenderIfNeeded(@Nullable IgniteClosure<Boolean, Logger> initLogClo) {
if (inited) {
// Do not init.
impl = initLogClo.apply(false);
return;
}
synchronized (mux) {
if (inited) {
// Do not init.
impl = initLogClo.apply(false);
return;
}
// Init logger impl.
impl = initLogClo.apply(true);
boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
boolean consoleAppenderFound = false;
Logger rootLogger = null;
for (Logger log = impl; log != null; ) {
if (!consoleAppenderFound) {
for (Appender appender : log.getAppenders().values()) {
if (appender instanceof ConsoleAppender) {
if ("CONSOLE_ERR".equals(appender.getName()))
continue;
consoleAppenderFound = true;
break;
}
}
}
if (log.getParent() == null) {
rootLogger = log;
break;
} else
log = log.getParent();
}
if (consoleAppenderFound && quiet)
// User configured console appender, but log is quiet.
quiet = false;
if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
// Console appender not found => we've looked through all categories up to root.
assert rootLogger != null;
// User launched ignite in verbose mode and did not add console appender with INFO level
// to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
consoleLog = createConsoleLogger();
}
quiet0 = quiet;
inited = true;
}
}
Aggregations