@Override
  public void run() {
    List<Transaction> records = new ArrayList<Transaction>();
    if (archivingEnabled == false) {
      log.info("Archiving has not been enabled");
      return;
    }
    while (isExit() == false) {
      records.clear();
      buffer.drainTo(records);
      PrintWriter wf = null;
      try {
        FileWriter ff = new FileWriter(filename, true);
        wf = new PrintWriter(ff);
      } catch (FileNotFoundException e) {
        log.error("Should not have happened for [" + filename + "]");
        continue;
      } catch (IOException e) {
        log.error("Cannot write to [" + filename + "]");
        setExit(true);
        continue;
      }

      TransactionLogRecord tlr = new TransactionLogRecord();
      for (Transaction t : records) {
        log.debug("Logging " + t);
        if (t instanceof ExitTransaction) {
          setExit(true);
          continue;
        }
        if (t.getDirection().equals(DirectionType.NONE)) {
          log.error("Transaction [" + t + "] is empty");
          continue;
        }
        wf.print(tlr.toString(t));
      }
      wf.close();
    }
    log.info("Archiving is ending");
  }