---
title: How log records arrive
description: Learn when log records reach a read of the logs and in what order, how a read waits for a record, and why a read can come back empty.
slug: /concepts/how-log-records-arrive
order: 14
visibility: public
redirects_from: []
---

# How log records arrive

Use `read_logs` with `source: "container"` for a server's console output. For a serverless function's console output and failures, use `source: "pool"` or omit `source`. Use `source: "app"` for records written through the Logging package. A missing line may reflect collection delay or a filter. For a server, a stopped container can also leave console lines unavailable. [Read logs and counters](/cloud/guides/read-logs-and-counters/) gives the calls.

## The store and the console

The sources `app`, `platform`, `router`, `egress`, `harness`, and `pool` read the logging service's stored records. Their responses include both formatted `lines` and parsed `entries`, with `at`, `level`, `source`, `message`, and any `fields`.

The `container` source reads a server environment's console and returns `lines` without `entries`. For a serverless application, an explicit `container` read returns 400 `invalid_request`. It defaults to production. It cannot read the `local` stream, because a local process has no console on the platform.

A read with no source returns records in time order within `limit`. For a server, it combines stored records and server console output. For a serverless application, it reads stored records, including function console lines from `pool`. Console lines appear as parsed `entries` with source `container`: standard error is level `error`, and standard output is `info`. Pod logs do not identify the stream, so all their lines are `info`. Setting `level`, `field`, `filter`, `contains`, or `until` excludes console output from a combined read.

Without `since`, a container app's console read covers the previous 24 hours. A pod read covers the logs of pods that still exist, oldest first. First it returns the lines Turn Zero kept when pods ended. It reads the last 24 hours by default, or starts at `since` if you set it. After a container restarts inside a pod, the previous container's lines come before the current container's. While the current container is waiting to start, only the previous container's lines are available. Setting an earlier `since` can retrieve older retained lines.

Pod reads also have a 262,144-byte window, in addition to the line limit. A line longer than that window, and lines before it, cannot be returned. The response's `detail` identifies a line cut by this limit.

## When the environment has no version or no compute

Production and development usually need deployment history for a stored log or counter read. On a one-environment app, `read_counters` can return earlier development totals where they still exist. With no development totals it reports that this app has no development environment. The `local` stream needs no deployment. A halted environment's stored records remain readable.

For a server with no compute, a `container` read returns 409 `deploy_in_flight` while a deploy or promote to that environment is in progress. The detail names the current deployment step and when that step started. Before the first step is recorded, it gives the version's start time instead. Use `read_status` with `wait_seconds` to follow it. Stored sources such as `platform`, `harness`, and `app` can already be read.

For a server environment with no deployment history, a `container` read also returns `deploy_in_flight` while a deploy upload is in progress. The detail identifies the upload and its grant's expiry. Use `read_status` with `wait_seconds` to follow it.

After a failed first deploy or promote, a console read can return up to 40 lines saved by its failed health check. These are also available at `deploy.outcome.gate.console` in `read_status`. The response's `failed_check` identifies the version, operation, and capture time. Lines written after that capture are not included.

This saved console remains in the version history until the application is deleted. `purge_logs` does not erase it. Console reads stop returning it after a later version runs or development is deleted. `since` and `wait_seconds` do not change this saved response.

For a server with no compute or saved health-check console, a `container` read returns `never_deployed` if no deploy, promote, or first deploy upload is in progress. The refusal explains what to do next. It says no compute runs there; it does not mean the code never ran. After a deployment failure, use `read_status` for its outcome and the stored log sources for available records. The refusal identifies the failed version and, when recorded, its step and error.

For a server's console read with no deployment history or upload, `detail` directs you to `deploy`, or to `promote` for production when the application has two environments.

If the health-check record proves the container ran, `detail` says it was removed. Evidence includes console lines, an application response, a running or ready instance, or a restart or exit.

If production has no version and development's first deployment failed, read development's saved console.

The `local` stream needs neither deployment history nor hosted compute.

## How long console lines last

Console retention depends on where the environment runs:

- **Pod:** console output lasts only while the pod exists. Scaling to zero or replacing the pod deletes it. A failed health check saves its last 40 lines before removing the new pod.
- **Lines kept at a pod's end:** Turn Zero saves the first 50 and last 250 lines per Node.js process that loads the harness under `start`. Each line is cut at 2,048 bytes, with up to 256 KiB per process. The lines count toward the `harness` [retained-bytes limit](/cloud/guides/read-logs-and-counters/#9-stay-under-the-retained-bytes-limit) and are kept up to twice that limit. A `container` read shows them as `[pod-ended]` before live pod lines, starting at `since` or 24 hours ago. Saved lines follow the app's log retention. With seven-day retention, the job can remove them after seven days. `purge_logs` erases them.
- **When Turn Zero saves no lines:** it saves none from a process that ends before the pod, such as a separate migration step in `start`. It also saves none from a child process that never receives SIGTERM. From a pod killed by the kernel or SIGKILL, or from a process that crashes, Turn Zero saves nothing. If sending the lines is refused, fails, or times out, none are saved. The process writes one `pod_console_keep_failed` line to the console instead.
- **Container app:** the hosting provider keeps console output for 30 days, including after a scale to zero. `purge_logs` does not erase that provider's copy.
- **Logging package:** records are stored separately and survive a pod's removal. Use it for logs you need to retain.

A pod response includes `console_since`, the earliest container start the live console still holds, and a `page` link explaining the response. Lines written before `console_since` are no longer in the live console. They can still return as ended-pod lines, which never move `console_since`. With no pod, `console_since` is null. If no ended-pod line falls in the window either, `detail` says that no live console exists until the environment starts. A response from following a console with `wait_seconds` includes neither field.

## When records arrive, and in what order

| Source | Typical delay |
| --- | --- |
| Logging package records | A few seconds while the client buffers them |
| Per-minute `router`, `egress`, and `harness` records | Until the minute ends |
| Container app console | Up to about a minute through the provider's log store; immediate from running replicas when direct reads succeed |
| Pod console | Available immediately |

Pod console reads have no ingestion-delay warning.

A stored-log read ends its window at `until`, or now if you omit it. An explicit `container` read ignores `until`. A combined read with `until` leaves out the server console. For stored logs, `detail` warns when recent records may still be arriving. Retry about a minute later when it reports collection delay.

For a container app, the platform can supplement stored logs by reading running replicas directly. The response explains whether that read succeeded and, if so, when the directly read lines begin. A later read can return the same lines from the store. If no replica was reached, a replica stopped or restarted, or the direct read did not finish, recent lines may still be arriving; retry after about a minute.

If the direct read fails, `reason` gives the failure, such as `timed_out`, `throttled`, or `http_503`. Stored lines can still be returned. They are the lines available in the store at that read; a later read can add recent lines that were still arriving. This failure describes log retrieval, not application health; use `read_status` to check health.

If a completed direct read adds no lines and finds no stopped or restarted replica or missing output, `detail` confirms that the response includes the replicas' newest lines. If direct reads are disabled, recent lines may still be arriving in the store; retry after about a minute. Turn Zero controls this setting for the whole platform.

The `detail` is limited to 600 characters and may omit secondary explanations. Read structured fields such as `reason` for the complete value.

Console lines have the form `<time> <stream> <text>`, ordered by when the process wrote them. The stream is `stdout` or `stderr`, or `-` for a pod.

During replacement, the old copy may still write output. The platform marks its lines `[retiring]` after the stream and counts them in `retiring_lines`. A marked `SIGTERM` or `npm error` therefore describes the old copy's shutdown. If every line is marked, the response contains no output from the serving version. Text your application writes that happens to begin with `[retiring]` is not counted. When space permits, `detail` also explains a retirement mark.

A container app's shutdown after an idle period is marked `[idle-stop]`. The next request starts it again. A read within about a minute of the stop, or with a window beginning after it, may leave these lines unmarked. [Status and logs](/cloud/troubleshooting/status-and-logs/#the-logs-show-sigterm-lines-after-a-promote-or-while-the-application-is-idle) explains both marks.

On a pod, each ended-pod line is marked `[pod-ended]` after the stream. Its time is when its process wrote the line, not when the cluster recorded it. If the pod's copy is being replaced, `[retiring]` comes first: `<time> - [retiring] [pod-ended] <text>`. Only lines marked `[retiring]` count in `retiring_lines`. A new version can reuse an ended pod's name, so a `[pod-ended]` line can come from an earlier version, such as one that failed its health check. The mark says that the pod ended, not which version wrote the line.

## How a wait ends

Set `wait_seconds` to a whole number from 1 to 45 to wait for a matching record. The response includes `waited_ms`.

For stored logs, the platform checks every two seconds until it finds a match or the wait expires. With `field: "request_id"` and no `source`, it can keep waiting after the first match. It stops when both `router` and `app` match, the wait expires, or a check about three seconds or more after the first match finds nothing new. A 5xx can return both sources together, or just one if the other was capped, never written or has yet to arrive. A 4xx has no per-request router record. Set `since` to wait for newer entries only.

Each platform server allows one wait per application at a time, shared by log reads, status reads, and actions such as `deploy`. A competing stored-log wait returns immediately and explains why.

A `container` wait follows up to three running container-app replicas, or the newest pod. It returns when a matching line arrives or the wait ends. This wait is capped at 40 seconds, even if `wait_seconds` is higher. Without `since`, retained lines can satisfy it immediately.

Turn Zero enables or disables direct reads for the whole platform. If disabled, a `container` wait returns an ordinary console read immediately; `detail` says direct reads are off. Waiting longer does not change that setting.

If another wait is running, follow capacity is full, or the hosting provider's API is near its limit, the platform returns an ordinary console read and explains the reason. Retry later or omit the wait. If the provider nears its limit during a wait, the response contains the lines collected so far.

If no instance is running, or every followed stream closes, the platform checks once more after ten seconds. It follows any new instance, without checking a third time. Container-app waits then continue to their deadline and include stored lines; pod waits return what they have.

A wait follows only the current container. To read the previous container's output after a crash, make an ordinary `container` read without `wait_seconds`.

## Why a read comes back empty

Check the response's `detail`:

- **`app`:** this source contains Logging package records, not console output.
- **`container`:** no copy may be running, the pod's console may have been deleted, or recent lines may still be arriving. With `contains`, the response reports how many lines were searched and matched, and how many the `filter` kept when supplied. A direct read can reach a replica and still find no lines. The empty response's `detail` says the compute may have scaled to zero. When the read completes with no failure, stopped or restarted replica, or missing output, the detail omits the collection-delay warning.
- **Other stored sources:** no record exists in the window or matches the filters.
- **All sources:** no stored or console line matches. If console output was excluded, the response explains why.

A combined read reports whether it includes console output. An `answered_5xx` router record usually points to the console read needed to find the application's error. If that record belongs to a pod version that no longer serves, the response identifies the version instead, since an ended pod keeps only its first and last lines.

## Related

- [Read logs and counters](/cloud/guides/read-logs-and-counters/) chooses sources and filters.
- [Status and logs](/cloud/troubleshooting/status-and-logs/) explains missing lines and shutdown messages.
- [The deploy health check](/cloud/concepts/the-deploy-health-check/) explains saved failure evidence.
- [Applications and environments](/cloud/concepts/applications-and-environments/) explains containers and pods.
- [read_logs](/cloud/reference/actions/read-logs/) lists every argument and response field.
