---
title: "append to log · RUAL Documentation"
description: "Appends an entry to an ordered log per key: an order's status event, an audit record, a chat message. It takes the key's next sequence and is written th…"
canonical: https://docs.rual.nl/block-types/data/log_append
language: en
---

# append to log

This block is part of the [`data`](https://docs.rual.nl/block-types/data) group and was last modified in core [`v15.0.2`](https://docs.rual.nl/core-versions/150002).

Appends an entry to an ordered log per key: an order's status event, an audit record, a chat message. It takes the key's next sequence and is written through the storage.

- flow

- storage `value` required the storage the log's entries are documents of; it names the log

- key `value` required the log within the storage: an order, an account, a channel

- id `value` required the entry's id, unique within its key

- document `object` required the entry's own fields

- actor `value` who appends; with nonce, what a retry is recognised by. The run's socket's user by default

- nonce `value` the caller's own id for this append, so a retry is not a second entry

- group `value` gathers keys whose heads are read together (log_heads): the orders of a shop, the channels of a server

- key field `value` the field that holds the key; log_key by default

Default `log_key`

- id field `value` the field that holds the entry's id; id by default

Default `id`

- created field `value` the field that holds the created sequence; created_seq by default

Default `created_seq`

- changed field `value` the field that holds the changed sequence; changed_seq by default

Default `changed_seq`

- flow

- success `condition`

- found `condition`

- entry `object`

- guid `value`

- seq `number`

- previous id `value`

- duplicate `condition`

- error `value`

Allocates the key's next sequence, writes doc through the storage with the key, the id and the created and changed sequences set (field names from the four *_field pins) and a GUID derived from the storage, the key and the id, then records the entry in the Redis hot tail, the latest-entries cache, the key's head, and the group's heads when group is set. Example: storage order_events, key the order guid, id the event id, doc {status: "paid"}, group the shop. A retry with the same actor and nonce (a webhook's delivery id, a client's temporary id) returns the committed entry with duplicate=true and writes nothing; the nonce is reserved before the write, so a retry that arrives while the first call is still writing fails with APPEND_PENDING (try again shortly) instead of appending twice, and an append that failed before its document landed is not remembered. An append never replaces an entry: an id the key already has fails with ID_EXISTS, unless it is the same append sent again (same actor and nonce). prev_id is the key's head before this entry. Run it under a socket method's or lock's serialize on the key so commits and whatever announces them leave in one order. actor defaults to the run's socket's user. storage, key and id are required (STORAGE_REQUIRED, KEY_REQUIRED, ID_REQUIRED on error); LOG_NOT_ENABLED when the node runs no log. A sequence is a millisecond stamp from the key's own clock, max(now ms, the key's last + 1), so it is strictly increasing per key in commit order and compares with a cursor (cursor_set, cursor_lag).

## Version history

Introduced in [`v15.0.2`](https://docs.rual.nl/core-versions/150002).

- [`v15.0.2`](https://docs.rual.nl/core-versions/150002): block added in this release.

- [Back to `data`](https://docs.rual.nl/block-types/data): Return to the main group to view all sub-groups

- [Back to `ordered log`](https://docs.rual.nl/block-types/data?group=ordered%20log): Return to the group to view all blocks within this group
