> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ancha.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs describe the Ancha CLI, npm package @ancha-labs/cli version 0.1.4, and the hosted workspace at app.ancha.io. Coding agents should start at https://docs.ancha.io/coding-agents. Run the CLI as `ancha` after `npm install -g @ancha-labs/cli`, or as `npx -y @ancha-labs/cli@0.1.4` without installing. Pass --json for machine-readable output, or set ANCHA_JSON=1. Every command ends with a `next:` line naming the next command. Exit codes: 0 pass, 1 a check failed or a comparison regressed, 2 usage, config or authentication error, 3 infrastructure error, 4 unimplemented endpoint with --strict.

# ancha logs

> Print a run's events, as text or NDJSON, and follow a detached run until it ends, exiting with the run's own exit code.

`ancha logs` prints the events of a run: `run_started`, then `trial_started` and `trial_finished` for each trial. With `--follow`, it keeps printing new events until the run ends and exits with the run's exit code. Use it to watch a run started with `ancha run --detach`.

```bash theme={null}
ancha logs [options] <id>
```

| Argument | Description |
| - | - |
| `id` | Run id, or latest |

| Option | Description |
| - | - |
| `--out <dir>` | Run directory (default: .ancha/runs) |
| `--follow` | Keep printing new events until the run ends, then exit with its exit code |

## Example

```bash theme={null}
ancha run --detach --json      # {"event":"run_detached","runId":"run_20261031-103409_8f819f1bcc93287c"}
ancha logs run_20261031-103409_8f819f1bcc93287c --follow
```

```text Output theme={null}
run_started runId=run_20261031-103409_8f819f1bcc93287c scenes=["starter"] trials=1 parallel=1 workspace=local:/path/to/project target=local
trial_started scene=starter trial=1 envId=dc76xmkw
trial_finished scene=starter trial=1 passed=false valid=true warnings=[] exit=exited exitCode=0 realMs=118 failedChecks=["github_access","datadog_access","pagerduty_access"]
```

Here the run failed a check, so `logs --follow` exits `1`. With `--json`, the same events print as NDJSON, one object per line, the same objects `ancha run --json` prints. See [For coding agents](https://docs.ancha.io/coding-agents.md#json-output) for their fields.

`latest` is the newest completed run. Without one, `logs latest` exits `2` with `no finished run yet` and the hint `ancha logs <run id>; ancha run --detach prints one`. If you passed `--out` to `ancha run`, pass the same `--out` here.

Pressing Ctrl-C stops `logs` only; the run keeps going. [`ancha wait`](https://docs.ancha.io/cli/wait) prints progress and then the run's summary instead of the raw events, and [`ancha status`](https://docs.ancha.io/cli/status) prints one line with the run's state.

## Exit codes

Without `--follow`: `0` when the run exists. With `--follow`: the run's own exit code, `0` to `4`, or `3` when the run's worker stopped reporting and the outcome is unknown. `2` for an unknown run id or no finished run.


## Related topics

- [ancha wait](https://docs.ancha.io/cli/wait.md)
- [ancha run](https://docs.ancha.io/cli/run.md)
- [Troubleshooting](https://docs.ancha.io/troubleshooting.md)
- [Attempts and runs](https://docs.ancha.io/concepts/attempts-and-runs.md)
- [ancha status](https://docs.ancha.io/cli/status.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.