Skip to content

Logs

Search the requests your app served and what it printed, and follow them live.

View as Markdown

Logs, in a project's sidebar, lists the requests your app served, newest first. Choose a request to read its console.log, console.warn and console.error output in the separate Console section of its details. Middleware output is marked middleware.

Times are shown in your time zone, which the line over the list names; see Account settings. Build logs are on each deployment's page; see Builds and deployments.

Search and filter

  • Search messages, paths, or request IDs… finds requests by their details or the messages and data they logged. Request details include the method, URL, rewritten path, user agent, status, outcome, request ID, Ray ID, cron schedule and visitor's IP address.
  • Period: from Last 15 minutes to Last 7 days. Last hour is the default.
  • Level: Warnings and errors, or Errors only, including console output from the same invocation. A request that returned 200 can still match because it logged a warning or error.
  • Status: requests that answered 4xx or 5xx.

Search also finds Custom Context keys and values, and the HTTP request ID that links middleware and application logs. Copy a value from the details or choose its filter link.

Resume live checks the list and the open request's console every 10 seconds using 20-second log snapshots while the tab is visible; it pauses by itself after 10 minutes.

A request's details

Choose a request to see its duration, CPU time and request ID. Its Console loads separately and shows that invocation's recorded output, oldest first, including multiline messages and structured Logged data. Loading older output pauses the console's automatic updates so its history stays in place; Refresh console returns to the latest output. The request list can keep following live independently. The list's search, level and status filters do not hide console lines. Load older output reads earlier output without changing the request list. Sampling, truncation and incomplete reads are indicated; an empty console does not imply that the app never wrote output. A request's details also show:

  • Kind: what Next.js was asked for — Server Action, Prefetch, RSC (a client-side navigation), Resume (the rest of a page after the edge sent its prerendered shell), Regeneration (ISR) or Cron job. A request that is none of these, such as a page rendered whole or a route handler, has no kind.
  • Cold start, when a new instance of your app was started for the request.
  • URL, with the host it was asked on, and Rewritten from, the path the visitor asked for when your middleware rewrote it.
  • User agent: the one your app was asked with. It is the visitor's, unless your middleware set the request's user-agent header; then it is the one your middleware set.
  • Ray ID, Cloudflare's ID for the request, with Filter by this Ray ID.
  • Deployment: production or a preview, with the branch and commit it was built from. Choose it to open the deployment.
  • Visitor: the IP address and country of the visitor behind the request, and the CDN location recorded for it. A regeneration the edge asks for after a response shows the visitor whose request led to it. Filter by this IP address searches the logs for that address.

The list marks a request with its kind, middleware when your middleware answered it, Preview when a preview deployment did, and Cold start.

Custom Context

Pass your own user, tenant or other identifiers from server code with setLogContext from @stayingupwind/sdk/logs. Use the authenticated session your application already reads. Arkor does not extract IDs from cookies automatically.

In a Next.js Route Handler that already authenticates the request, capture the IDs and emit them with after, after the response:

import { setLogContext } from '@stayingupwind/sdk/logs';
import { after } from 'next/server';

import { authenticate, handleRequest } from '@/lib/application';

export async function POST(request: Request) {
  const session = await authenticate(request);
  const context = { userId: session.userId, tenantId: session.tenantId };
  after(() => {
    setLogContext(context);
  });
  return handleRequest(request, session);
}

Call once with the complete map in the Worker that has resolved the session. Keys and values must be strings. You can pass up to 16 entries, with keys of 1–64 UTF-16 code units and values of up to 200 UTF-16 code units (JavaScript string lengths). The complete log record, including its envelope, must fit within 4,096 UTF-8 bytes. Invalid or oversized input returns false and emits nothing; valid input returns true when emitted. It makes no network request and keeps no global request state. Logging availability and sampling still determine whether it is retained.

The request and its log lines show the masked identifiers under Custom Context, including lines written before the call. When request correlation is available, the logs page also links middleware and application Workers serving the same HTTP request and deployment. HTTP request ID filters across those Workers; Request ID continues to identify one Worker invocation.

Repeated identical maps are accepted. Different maps within one invocation are ambiguous: its context is omitted. If middleware and app supply different maps, each keeps its own context and the page stops sharing it between Workers. The page warns that context search may be incomplete. Missing, sampled or truncated logs and a context lookup that cannot finish can produce the same warning. Refresh the page or shorten the period. Older deployments without correlation metadata can still show their own invocation's context.

Capture IDs from authentication already performed by the handler or an already dynamic component. Adding a cookie read to a shared Server Component just for logging can change caching and prerendering. A Server Component's after callback cannot read cookies() or headers(); pass captured values into it. In other frameworks, use an existing response-lifetime hook or call the synchronous API where the session is already available. Pass identifiers rather than session cookies or credentials. Everyone who can read the project's logs can read the unmasked IDs.

Log Drains export context from the invocation that emitted it, along with its HTTP correlation ID when available.

What is in the logs

  • Lines are kept for 7 days.
  • A secret's value is shown as *** wherever it appears; see Environment variables.
  • A request the edge answered without running your app, such as a static file or a page sent whole from the edge, is not in the logs.
  • The page shows the first 2,000 characters of a line, and 4,000 of what it logged beside its message, and says when it left the rest out. A line longer than 256 KB is cut short when it is logged.
  • A Server Action that a form posts without JavaScript shows as a plain POST. Every kind but Resume and Regeneration comes from the request's headers, as the client sent them or your middleware set them, so a client can claim one it is not.
  • Over a long period with many lines, Arkor may read a sample; the page then says Some lines are missing. A search that cannot associate matching console output with a retained request warns that some matching requests may be missing.

Everyone in the team can read a project's logs, visitors' IP addresses and requests' user agents included.