@Override public void addErrorLogAppender(Object aAppender) { Appender appender = (Appender)aAppender; LevelFilter filter = new LevelFilter(); filter.setContext((LoggerContext) LoggerFactory.getILoggerFactory()); filter.setLevel(Level.ERROR); filter.setOnMatch(FilterReply.ACCEPT); filter.setOnMismatch(FilterReply.DENY); filter.start(); appender.addFilter(filter); appender.setContext((LoggerContext) LoggerFactory.getILoggerFactory()); appender.start(); ((Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).addAppender(appender); }
private static void init() { ConsoleAppender<ILoggingEvent> defaultAppender = new ConsoleAppender<>(); defaultAppender.setContext((LoggerContext) LoggerFactory.getILoggerFactory()); defaultAppender.setName(DEFAULT_APPENDER_NAME); LevelFilter levelFilter = new LevelFilter(); levelFilter.setLevel(Level.ERROR); defaultAppender.addFilter(levelFilter); // if output is not set for thread, keep default behavior (configured to stdout) setCustomRootAppender(defaultAppender); }