Skip to main content
Mirage logs every command a session runs. Each entry holds the command, its exit code, the first 4096 characters of its stdout and stderr, and every call the command made to a mount.
A session runs a line
↓→
Command logs
in memory or on disk
↓→
Read them with
history/.bash_historymirage workspace logsws.history()
With an OpenTelemetry SDK set up, Mirage also sends each line out as a trace. Logs and traces compares the two.

Reading logs

mirage shell --no-record runs a line without logging it.

Example

Run three lines in a workspace that mounts a RAM folder at /data.
While the second line runs, Mirage writes three records for it: mirage workspace logs -w demo lists the lines newest first. This is the entry for the second line. mounts lists the read that wc made, and cwd is where the line started.
The failed cat has its own entry with "exit_code": 1 and the error in stderr. mirage workspace logs -w demo --jsonl and ws.history(vfs=True) return the same line as three records, linked by parent:

Log entries

Mirage splits input into entries the same way bash does. A set -e failure stops a line the same way exit does. If a post_execute policy checks a line, Mirage writes the entry after the policy answers. Output that the policy drops never reaches the logs.

Log storage

A workspace you build in code keeps its logs in memory. A workspace the server builds keeps them on disk under ~/.mirage/state. Logs grow with every command, so store.observer moves them without moving the rest of the workspace state. Redis does not hold logs. With store.type: redis, Mirage writes the logs to disk under the store’s root, unless store.observer names another backend. To collect logs from several machines in one place, export them as traces. This config keeps the rest of the workspace state on Redis and the logs on local disk.

Logs and traces

Mirage keeps command logs itself and serves them back to you, to the agent and to policies. Traces carry the same activity out to an OpenTelemetry backend, and Mirage keeps no copy of them. Use command logs when the agent, a policy or you need to look back at what a workspace ran. Use traces to watch many machines in one place, with your tool’s search, retention and alerts.

Restarts

Each log belongs to a session. A rebuilt workspace shows a session’s logs only after it has that session again. To keep logs across a restart, do one of these.
  • Keep the sessions on a store that survives a restart.
  • Give the default session a fixed id with default_session_id.