# div logs

> Print a run's log, or follow it until the run ends.

## Synopsis

```text
div logs <run> [flags]
```

Prints a run's log: the run's stdout on stdout and its stderr on stderr.

## Arguments

| Argument | Description |
| --- | --- |
| `<run>` | Run name or ID. |

## Flags

| Flag | Description | Default |
| --- | --- | --- |
| `-f`, `--follow` | Keep printing new lines until the run ends. | |
| `--since <seq>` | Start after this line number. | `0` |
| `--limit <n>` | Maximum lines to print without `--follow`. Maximum 500. | `500` |
| `--json` | Print the lines as JSON, with their sequence numbers. | |
| `--token <key>` | API key to use. | see [Configuration](https://docs.divergentlabs.xyz/compute/cli/configuration.md) |
| `--api-url <url>` | API URL to use. | see [Configuration](https://docs.divergentlabs.xyz/compute/cli/configuration.md) |

## Output

Each log line is printed as the run wrote it, with nothing added. With `--follow`, `div logs` prints one line to stderr when the run ends, in the same form as [`div run`](https://docs.divergentlabs.xyz/compute/cli/run.md#output). If the connection drops, `--follow` reconnects and continues from the last line printed.

With `--json`, each line includes its sequence number (`seq`). Pass the last `seq` to `--since` to continue from there.

## Exit codes

| Code | Meaning |
| --- | --- |
| the run's exit code | The run has finished. |
| `0` | The run is still going (without `--follow`), or it succeeded. |
| `1` | The run stopped without an exit code, or the API rejected the request. |
| `2` | Invalid flags or arguments. |

## Examples

```bash
div logs training-run-4 -f
div logs run-7 -f | grep loss
div logs run-7 --json | tail -1
div logs run-7 --since 4200 -f
```
