---
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 `console.log` and `console.error` output. Use `source: "app"` for records written through the Logging package. A missing line may reflect collection delay, a filter, or a stopped container. [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 the environment's console and returns `lines` without `entries`. 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 combines stored records and console output, in time order within `limit`. 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. Before those, it returns the ended-pod lines of the previous 24 hours, or from `since`. 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

For stored log sources and `read_counters`, an environment needs a deploy or promote in its history. Without it, the read returns `never_deployed`. A halted environment's stored records remain readable.

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.

Before any deployment history exists, a `container` read also returns `deploy_in_flight` while a deploy upload is in progress for that environment. 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.

If no compute or saved health-check console exists and no deploy, promote, or first deploy upload is in progress, a `container` read returns `never_deployed`. 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 console read with no deployment history or upload, `detail` directs you to `deploy`, or `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:** when a pod ends, the platform keeps the first 50 and the last 250 lines each process your `start` script runs wrote, for 30 days. These are the ended-pod lines. Each is cut at 2,048 bytes, and a process's lines stop at 256 KiB, so a flood keeps fewer of its last lines. They count toward the `harness` retained-bytes limit and are kept up to twice it ([limits](/cloud/guides/read-logs-and-counters/#9-stay-under-the-retained-bytes-limit)). A `container` read returns them before the lines of pods still standing, each marked `[pod-ended]`. It reads them from `since`, or from the previous 24 hours without it. `purge_logs` erases them.
- **What keeps nothing:** a process that ends before the pod does, such as a migration run as its own step of `start`, keeps nothing, and neither does a child process that SIGTERM never reaches. No lines are saved from a pod killed by the kernel or SIGKILL, or from a process that crashes. 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 read covers the period ending at `until`, or now if it is omitted. Its `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 a matching entry exists or the wait expires. An existing match ends the wait immediately. A read by `field: "request_id"` with no `source` does not end at its first match. It waits until both the `router` and `app` sources have answered, or until about three seconds pass with no new entry. A 5xx's router record and your entries therefore return together. A 4xx has no router record, so the read returns your entries alone. 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. If a direct read reaches a replica and finds no lines, failures, stopped or restarted replicas, or missing output, the empty response's `detail` mentions scale to zero without warning of collection delay.
- **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.
