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

# Logs

> Read runtime output and platform-generated invocation logs for Edge Compute functions.

Edge Compute exposes two log types through the same CLI command and API endpoint:

| Type | Source | What it contains |
| - | - | - |
| `runtime` | Your function | stdout/stderr such as `console.log`, `console.error`, and uncaught exceptions |
| `invocations` | Edge Compute platform | One record for each HTTP request served, even when your function writes no logs |

## Runtime logs

Runtime logs are the default:

```bash theme={null}
telnyx-edge logs my-func
telnyx-edge logs my-func --type runtime
telnyx-edge logs my-func --since 10m
telnyx-edge logs my-func --last 200
telnyx-edge logs my-func --json
```

Each line prints as `[timestamp] [level] message`, oldest first. The level is best-effort and can be inaccurate on stack traces; a multi-line error arrives as several separate entries.

## Invocation logs

Use `--type invocations` for platform-generated request records:

```bash theme={null}
telnyx-edge logs my-func --type invocations
telnyx-edge logs my-func --type invocations --since 10m
telnyx-edge logs my-func --type invocations --last 200
telnyx-edge logs my-func --type invocations --json
```

Invocation logs report traffic even when your code never calls `console.log`. Each record includes request metadata such as timestamp, HTTP method, path, status code, duration, request and response size, and serving region when available.

`--since`, `--last`, and `--json` work the same way for both log types. `--since` defaults to `1h` and is capped at `24h`; `--last` defaults to `50` and is capped at `250`. Results are returned oldest first.

The API exposes both streams through `GET /v2/compute/funcs/{id}/logs` with `type=runtime` or `type=invocations`. See the [API Reference](/docs/edge-compute/observability/api-reference).

## Tail logs live

> **Requires CLI v0.5.3 or newer.**

```bash theme={null}
telnyx-edge logs my-func --tail
telnyx-edge logs my-func --tail --type invocations
telnyx-edge logs my-func --tail --json
```

`--tail` switches from the default read-a-window-and-exit behavior to a live stream: the CLI stays attached and prints new log lines as the platform receives them, until you press Ctrl-C. The stream is delivered over a WebSocket direct from the ingest pipeline — there is no polling and no history: only lines written while you are attached arrive.

| Flag | Description |
| - | - |
| `--tail` | Stream new log lines live instead of reading history |
| `--type` | In tail mode, `runtime` or `invocations`; omitted, tail shows both interleaved |

In tail mode, `--since` and `--last` are meaningless (there is no history to page through) and are silently ignored. `--type` means something different here than in the one-shot read: an unset `--type` shows **both** runtime and invocation lines, interleaved as they arrive; pass `--type runtime` or `--type invocations` to filter to one kind. With `--json`, each line is one JSON object in the shape of the record that arrived.

If the connection drops, the CLI reconnects with capped backoff and keeps streaming.

## Emit custom events to a sink you run

Runtime and invocation logs cover platform-retained logs. If you also need application-specific structured events in your own system, send them over HTTPS to a collector you control. Store the collector credential as a [secret](/docs/edge-compute/configuration/secrets), never in code.

Declare the secret in `func.toml`:

```toml theme={null}
[[secrets]]
binding = "LOG_SINK_KEY"
name    = "LOG_SINK_KEY"
```

```bash theme={null}
telnyx-edge secrets add LOG_SINK_KEY "<your collector's API key>"
telnyx-edge types
```

Keep telemetry off the response's critical path, apply an outbound timeout, and do not let a failed telemetry request fail the function response. Log metadata rather than sensitive request payloads.

See the [CLI reference](/docs/edge-compute/reference/cli#logs) for the full command reference.
