Next.js Logging Nightmare: A Struggle with Production Logging

2025-09-02
Next.js Logging Nightmare: A Struggle with Production Logging

The author encountered a series of challenges while attempting to add production logging to a Next.js service. Next.js's middleware mechanism is heavily restricted, and AsyncLocalStorage couldn't bridge the rendering context, resulting in logging failures in pages and layout components. The author tried various methods, including a custom server, ultimately discovering that Next.js's design limited the implementation of logging features. A comparison with SvelteKit highlights Next.js's shortcomings in logging and the inefficiency of its GitHub issue tracker. The author expresses dissatisfaction with Next.js and considers alternatives for future projects.

Development