Back to articles
How to Add Structured Logging to Node.js APIs with Pino 9 + OpenTelemetry (2026 Guide)
How-ToDevOps

How to Add Structured Logging to Node.js APIs with Pino 9 + OpenTelemetry (2026 Guide)

via Dev.to DevOps1xApi

Logging is the first thing you reach for when something breaks in production. Yet most Node.js APIs still write plain-text console.log statements that are useless in a distributed system. In 2026, structured JSON logging correlated with distributed traces is the baseline for any serious API. This guide shows you exactly how to wire up Pino 9 + OpenTelemetry so that every log line carries a traceId and spanId , making root-cause analysis a matter of seconds rather than hours. Why console.log Kills You at Scale Before diving in, let's be concrete about the problem. A log like this: [2026-04-01T08:00:12.345Z] ERROR: Payment failed for user 8821 Is useless when you have 50 services and 10,000 concurrent requests. Questions you cannot answer: Which request triggered this? (no requestId ) Which upstream call failed? (no traceId ) What was the user's cart value? (no business context) How long did it take to reach this point? (no timing) Structured logging + trace correlation solves all of thi

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
5 views

Related Articles