class Log4jAppender extends AppenderSkeleton {

  @Override
  public synchronized void append(LoggingEvent event) throws FlumeException {
    //If rpcClient is null, it means either this appender object was never
    //setup by setting hostname and port and then calling activateOptions
    //or this appender object was closed by calling close(), so we throw an
    //exception to show the appender is no longer accessible.
    if (rpcClient == null) {
      String errorMsg = "Cannot Append to Appender! Appender either closed or" +
          " not setup correctly!";
      LogLog.error(errorMsg);
      if (unsafeMode) {
        return;
      }
      throw new FlumeException(errorMsg);
    }

    if (!rpcClient.isActive()) {
      reconnect();
    }

    List<Event> flumeEvents = parseEvents(event);
    try {
      switch (flumeEvents.size()) {
        case 0:
          break;
        case 1:
          rpcClient.append(flumeEvents.get(0));
          break;
        default:
          rpcClient.appendBatch(flumeEvents);
      }
    } catch (EventDeliveryException e) {
      String msg = "Flume append() failed.";
      LogLog.error(msg);
      if (unsafeMode) {
        return;
      }
      throw new FlumeException(msg + " Exception follows.", e);
    }
  }

  public  Log4jAppender();
  public  Log4jAppender(String hostname, int port);

}