# Logs

This page says where an app's lines go and how to read them. It teaches
`durable-sdk logs [--env production|preview] [--level info|error] [-q
<text>] [--follow]` and `durable-sdk deployments events <id>`.

## Runtime logs

```bash
durable-sdk logs
durable-sdk logs --env preview --level error
durable-sdk logs -q "hello.say" --follow
```

```text
12:04:31 info  run hello.say 01J… COMPLETED in 18 ms
12:04:31 info  fact hello.said delivered to listener hello.record
12:05:00 info  dispatch: 0 due, 0 parked, 1 drained
```

- The stream is the environment's current deployment's, read live for
  30 seconds, or up to five minutes under `--follow`, at most 256 lines
  an answer. There is no `--since`: a window older than the stream is
  the deployment's own record (below) or your own sink.
- `--level` and `-q` filter on the platform before the lines reach you.
- Every line passes the redaction shapes (a connection string, a key, a
  bearer) and the masking filter (a provider hostname or id becomes the
  product's hostname or `<platform>`) and is cut at 4 KB. Your own
  words are never changed.
- The answer carries `retentionDays`, the window the lines stay
  readable; a drain into the platform's own sink with the tier's
  retention is coming (DS-023).

The engine's own lines are catalogued (`run.*`, `step.*`, `dispatch`,
`listener.*`) and never carry an input, an output or an image: the
console shows those ([Console](https://durablesdk.com/docs/operate/console.md)). A line your code
logs is yours; the logger refuses a `Secret` and the redaction policy
names the shapes it blanks ([Ledger and data](https://durablesdk.com/docs/concepts/ledger-and-data.md)).

## Build logs

```bash
durable-sdk deployments events <id> [--since <instant>]
```

```text
12:03:50 info  Installing dependencies…
12:04:02 info  > durable-sdk migrate --baseline=if-missing
12:04:03 info  schema durable at 29 (baseline written)
12:04:11 info  > tsc --noEmit
12:04:20 info  Build completed
12:04:25 info  check health ok · api 2.142 · ledger ok · limits ok · instance production
```

The lines are stored on the deployment (at most 2 000), redacted and
masked at read, kept 30 days. `durable-sdk deploy` follows them live;
the dashboard's deployment page shows them with the check's rows.

## Reading the engine instead

Most questions a log answers, the engine answers better from its rows:

| Question                   | Where                                                                                |
| -------------------------- | ------------------------------------------------------------------------------------ |
| what did this run do       | the Console tab: the run, its steps, each step's before and after image              |
| why is this run stuck      | `durable-sdk runs limbo` for a platform run; the Console's Limbo page for your app's |
| what changed in this table | `SELECT … FROM durable.ledger` through the [read string](https://durablesdk.com/docs/hosting/database.md)     |
| is the deployment healthy  | `curl https://<app>.durablesdk.com/health`; `GET /apps/:slug/status`                 |

## Scope

`logs` and `deployments events` need a key of scope `read`.

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/hosting/logs.md, then read an app's runtime and build logs on durablesdk.com; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
