code: @Override
    public void append(Transaction txn) throws IOException {
      if(txn.getZxid().compareTo(this.lastSeenZxid) <= 0) {
        LOG.error("Cannot append {}. lastSeenZxid = {}",
                  txn.getZxid(), this.lastSeenZxid);
        throw new RuntimeException("The id of the transaction is less "
            + "than the id of last seen transaction");
      }
      try {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        DataOutputStream dout = new DataOutputStream(bout);
        ByteBuffer payload = txn.getBody();
        // The number of bytes for Zxid + Type + payload.
        int length = payload.remaining() + ZXID_LENGTH + TYPE_LENGTH;
        // Writes the length.
        dout.writeInt(length);
        // Writes Zxid.
        dout.writeLong(txn.getZxid().getEpoch());
        dout.writeLong(txn.getZxid().getXid());
        // Writes the type of the transaction.
        dout.writeInt(txn.getType());
        // Writes the body of the transaction.
        while (payload.hasRemaining()) {
          dout.writeByte(payload.get());
        }
        dout.flush();
        byte[] blob = bout.toByteArray();
        // Calculates the checksum.
        Adler32 checksum = new Adler32();
        checksum.update(blob);
        // Gets the checksum value.
        int checksumValue = (int)checksum.getValue();
        this.logStream.writeInt(checksumValue);
        this.logStream.write(blob);
        this.logStream.flush();
        // Update last seen Zxid.
        this.lastSeenZxid = txn.getZxid();
      } catch(IOException e) {
        this.logStream.close();
      }
    }
docs: Appends a request to transaction log.
  
  @param txn the transaction which will be added to log.
  @throws IOException in case of IO failure