logging

Configure logging behavior in the terminal when running Next.js in development mode, including fetch logging, incoming requests, and forwarding browser console logs to the terminal.

Options

Incoming Requests

By default all the incoming requests will be logged in the console during development. You can use the incomingRequests option to decide which requests to ignore. Since this is only logged in development, this option doesn't affect production builds.

next.config.js
module.exports = {
  logging: {
    incomingRequests: {
      ignore: [/\api\/v1\/health/],
    },
  },
}

Or you can disable incoming request logging by setting incomingRequests to false.

next.config.js
module.exports = {
  logging: {
    incomingRequests: false,
  },
}

Browser Console Logs

You can forward browser console logs (such as console.log, console.warn, console.error) to the terminal during development. This is useful for debugging client-side code without needing to check the browser's developer tools.

next.config.js
module.exports = {
  logging: {
    browserToTerminal: true,
  },
}

Options

The browserToTerminal option accepts the following values:

ValueDescription
'warn'Forward only warnings and errors, by default
'error'Forward only errors
trueForward all console output (log, info, warn, error)
falseDisable browser log forwarding
next.config.js
module.exports = {
  logging: {
    browserToTerminal: 'warn',
  },
}

Source Location

When enabled, browser logs include source location information (file path and line number) by default. For example:

pages/index.tsx
export default function Home() {
  return (
    <button
      type="button"
      onClick={() => {
        console.log('Hello World')
      }}
    >
      Click me
    </button>
  )
}

Clicking the button prints this message to the terminal:

Terminal
[browser] Hello World (pages/index.tsx:6:17)

Disabling Logging

In addition, you can disable the development logging by setting logging to false.

next.config.js
module.exports = {
  logging: false,
}

Version History

VersionChanges
v16.2.0browserToTerminal added (moved from experimental.browserDebugInfoInTerminal)
v15.4.0experimental.browserDebugInfoInTerminal introduced
v15.2.0incomingRequests added
v15.0.0logging: false option added, fetches.hmrRefreshes added for App Router
v14.0.0logging.fetches moved to stable for App Router

On this page