DEV Community

Yarden Porat
Yarden Porat

Posted on

How to hide Next.js 14 server logs

Example for hiding logs such as:
GET /_next/static/chunks/app/route/react-toastify.esm.mjs.map 404 in 1623ms

// ./src/utils/customLogger.mjs

if (process.env.NODE_ENV === "development") {
  // Omit NextJS writing it's log https://github.com/vercel/next.js/discussions/65992
  const __write = process.stdout.write;
  process.stdout.write = (...args) => {
    if (typeof args[0] === "string" && args[0].startsWith(" GET /")) {
      if (args[0].includes("react-toastify.esm.mjs.map")) {
        return;
      }
    }
    __write.apply(process.stdout, args);
  };
}

export {};

Enter fullscreen mode Exit fullscreen mode
// next.config.mjs
import "./src/utils/customLogger.mjs";
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post