← All posts

Structured logging in Next.js without the noise

How to log from Route Handlers and server actions with one project token, environment tags, and readable messages.

Why structure matters

Unstructured console output breaks down the moment you add a second service. LoggerMan expects JSON-friendly messages with optional metadata — not giant string blobs.

Start with one project per deployable

Create a **Next.js API** template project, copy the ingest token, and set:

LOGGERMAN_PROJECT_ID=...
LOGGERMAN_TOKEN=...
LOGGERMAN_BASE_URL=https://your-deployment

Log at boundaries

  • **Request in / out** — method, path, status, durationMs
  • **Errors** — one ERROR line with `err` and a stable `code`
  • **Background work** — cron.started / cron.completed pairs

Environment tags

Pass `environment: "staging"` from the SDK so Analytics can compare staging vs production without separate projects.

Next steps

Wire alerts on ERROR rate, invite a teammate, and export CSV when auditors ask for a slice.