use of core.framework.impl.log.LoggerImpl in project core-ng-project by neowu.
the class ESLoggerConfigFactory method bindLogger.
public static void bindLogger() {
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration config = context.getConfiguration();
Map<String, ESLogger> loggers = Maps.newConcurrentHashMap();
Appender appender = new AbstractAppender("", null, null) {
@Override
public void append(LogEvent event) {
String name = event.getLoggerName();
ESLogger logger = loggers.computeIfAbsent(name, key -> new ESLogger(key, null, (LoggerImpl) LoggerFactory.getLogger(key)));
logger.log(event.getLevel(), event.getMarker(), event.getMessage(), event.getThrown());
}
};
appender.start();
config.addAppender(appender);
LoggerConfig loggerConfig = new LoggerConfig("", Level.ALL, false);
loggerConfig.addAppender(appender, null, null);
config.addLogger("", loggerConfig);
context.updateLoggers();
}
Aggregations