InstrumentedAppender extends AbstractAppender { @Override public void append(LogEvent event) { all.mark(); switch (event.getLevel().getStandardLevel()) { case TRACE: trace.mark(); break; case DEBUG: debug.mark(); break; case INFO: info.mark(); break; case WARN: warn.mark(); break; case ERROR: error.mark(); break; case FATAL: fatal.mark(); break; default: break; } } InstrumentedAppender(String registryName, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions);  InstrumentedAppender(String registryName);  InstrumentedAppender(MetricRegistry registry);  InstrumentedAppender(MetricRegistry registry, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions);  InstrumentedAppender(String appenderName, MetricRegistry registry); @PluginFactory static InstrumentedAppender createAppender(
            @PluginAttribute("name") String name,
            @PluginAttribute(value = "registryName", defaultString = "log4j2Metrics") String registry); @Override void start(); @Override void append(LogEvent event);  }
@Test public void metersTraceEvents() { when(event.getLevel()).thenReturn(Level.TRACE); appender.append(event); assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()) .isEqualTo(1); assertThat(registry.meter(METRIC_NAME_PREFIX + ".trace").getCount()) .isEqualTo(1); }
@Test public void metersDebugEvents() { when(event.getLevel()).thenReturn(Level.DEBUG); appender.append(event); assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()) .isEqualTo(1); assertThat(registry.meter(METRIC_NAME_PREFIX + ".debug").getCount()) .isEqualTo(1); }
@Test public void metersInfoEvents() { when(event.getLevel()).thenReturn(Level.INFO); appender.append(event); assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()) .isEqualTo(1); assertThat(registry.meter(METRIC_NAME_PREFIX + ".info").getCount()) .isEqualTo(1); }
@Test public void metersWarnEvents() { when(event.getLevel()).thenReturn(Level.WARN); appender.append(event); assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()) .isEqualTo(1); assertThat(registry.meter(METRIC_NAME_PREFIX + ".warn").getCount()) .isEqualTo(1); }
@Test public void metersErrorEvents() { when(event.getLevel()).thenReturn(Level.ERROR); appender.append(event); assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()) .isEqualTo(1); assertThat(registry.meter(METRIC_NAME_PREFIX + ".error").getCount()) .isEqualTo(1); }
@Test public void metersFatalEvents() { when(event.getLevel()).thenReturn(Level.FATAL); appender.append(event); assertThat(registry.meter(METRIC_NAME_PREFIX + ".all").getCount()) .isEqualTo(1); assertThat(registry.meter(METRIC_NAME_PREFIX + ".fatal").getCount()) .isEqualTo(1); }