public void append(LogEvent event) {
    Level level = event.getLevel();
    if (level.equals(Level.INFO)) {
      counts.incr(INFO);
    } else if (level.equals(Level.WARN)) {
      counts.incr(WARN);
    } else if (level.equals(Level.ERROR)) {
      counts.incr(ERROR);
    } else if (level.equals(Level.FATAL)) {
      counts.incr(FATAL);
    }
  }
A log4J2 Appender that simply counts logging events in four levels:
fatal, error, warn and info. The class name can be used in log4j2.properties
ql/src/java/org/apache/hadoop/hive/ql/log/HiveEventCounter.java