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

# substrate logs — Read Lines from the Persistent Log File

> substrate logs prints recent lines from .substrate/logs/substrate.log, written only by long-lived mcp and serve processes. Supports -n and --errors.

Run `substrate logs` to read the persistent log file written by the long-lived `substrate mcp` and `substrate serve` processes. The file is gitignored and local-only. Reading crosses a rotation boundary correctly, so `-n` is honoured even when the log just rotated.

## Usage

```shell theme={null}
substrate logs
substrate logs -n 200
substrate logs --errors
```

## Options

<ParamField path="-n" type="number">
  How many lines to print. Defaults to `50`.
</ParamField>

<ParamField path="--errors" type="flag">
  Filter to errors only.
</ParamField>

## Who Writes to the Log

Only the long-lived processes write here — `substrate mcp` and `substrate serve`. Short-lived commands do not log, so `substrate logs` after a failed one-shot command will not explain it.

An agent's handled tool errors land here, which makes `substrate logs --errors` the way an agent reviews its own error trail. Routine gate blocks and stale-version retries are excluded on purpose — they are normal operation, not faults.

## Empty States

| What you see       | What it means                                                 |
| ------------------ | ------------------------------------------------------------- |
| Log file is absent | The sink never ran — no `mcp` or `serve` has logged here yet. |
| Present, no errors | It ran cleanly.                                               |
