# MD_FLIGHT_LOGS
> Read the combined stdout and stderr captured during a Flight run.
Returns the captured logs for a single [Flight](/concepts/flights) run. The output combines stdout and stderr in the order the runtime captured them.

## Syntax

```sql
SELECT logs FROM MD_FLIGHT_LOGS(
    flight_id := '<flight_id>',
    run_number := <n>
);
```

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flight_id` | `UUID` | Yes | Identifier of the Flight. |
| `run_number` | `INTEGER` | Yes | The run number to fetch logs for. |

## Return columns

| Column | Type | Description |
|---|---|---|
| `logs` | `VARCHAR` | The full combined stdout/stderr captured during the run. |

## Behavior

- Returns an error when no run with the given `run_number` exists for the Flight, or when the Flight itself doesn't exist.
- Available for runs in any terminal status (`SUCCEEDED`, `FAILED`, `CANCELLED`) and during a `RUNNING` run.

## Examples

Read the latest run's logs:

```sql
WITH latest AS (
    SELECT run_number
    FROM MD_FLIGHT_RUNS(flight_id := '<flight_id>')
    ORDER BY run_number DESC LIMIT 1
)
SELECT logs
FROM latest, MD_FLIGHT_LOGS(flight_id := '<flight_id>', run_number := latest.run_number);
```

Read a specific run:

```sql
SELECT logs
FROM MD_FLIGHT_LOGS(
    flight_id := '80000000-0000-0000-0000-000000000001',
    run_number := 42
);
```

## Related

- [`MD_FLIGHT_RUNS`](../md-flight-runs) — Find the run number to read logs for.
- [`MD_RUN_FLIGHT`](../md-run-flight) — Trigger an on-demand run.
- [`get_flight_run_logs` MCP tool](/sql-reference/mcp/) — AI-agent equivalent, with a `max_bytes` cap.


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/flights/md-flight-logs/",
  "page_title": "MD_FLIGHT_LOGS",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
