Skip to content

logging

Last updated June 16, 2025

Options

Fetching

You can configure the logging level and whether the full URL is logged to the console when running Next.js in development mode.

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

Any fetch requests that are restored from the Server Components HMR cache are not logged by default. However, this can be enabled by setting logging.fetches.hmrRefreshes to true.

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

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:

app/page.tsx
'use client'
 
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 (app/page.tsx:8:17)

Disabling Logging

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

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

Was this helpful?

supported.