@Test
 public void testNoStart() {
   Appender<E> appender = getAppender();
   appender.setContext(context);
   appender.setName("doh");
   // is null OK?
   appender.doAppend(null);
   StatusChecker checker = new StatusChecker(context.getStatusManager());
   StatusPrinter.print(context);
   assertTrue(checker.containsMatch("Attempted to append to non started appender \\[doh\\]."));
 }
예제 #2
0
 @SuppressWarnings("unchecked")
 private static void writeEvent(LoggingEvent evt, Appender appender) {
   if (null == evt) {
     return;
   }
   if (null != appender) {
     appender.doAppend(evt);
   } else {
     System.out.println(evt.getFormattedMessage());
   }
 }
  public void process(ILoggingEvent event) {
    if (hold) {
      event.getThreadName(); // force "logback" to remember current thread
      events.add(event);
      if (event.getLevel().isGreaterOrEqual(Level.ERROR)) {
        hold = false;

        flushTraceLogs();

        events.clear();
      }
    } else {
      appender.doAppend(event);
    }
  }
 public void flushTraceLogs() {
   for (ILoggingEvent logEvent : events) {
     appender.doAppend(logEvent);
   }
 }