Unverified Commit c5c46992 authored by Joseph's avatar Joseph Committed by GitHub

docs: Move browserToTerminal into logging (#88901)

`browserToTerminal` stabilizes `browserDebugInfoInTerminal` - since it
lives under logging, let's remove the page and redirect to logging w/
fragment
parent 26306e7f
---
title: browserDebugInfoInTerminal
description: Forward browser console logs and errors to your terminal during development.
redirect: /docs/app/api-reference/config/next-config-js/logging#browser-console-logs
---
This configuration option has been moved to [`logging.browserToTerminal`](/docs/app/api-reference/config/next-config-js/logging#browser-console-logs).
## Migration
To migrate to the new configuration, replace `experimental.browserDebugInfoInTerminal` with `logging.browserToTerminal`:
```js filename="next.config.js"
// Before
module.exports = {
experimental: {
browserDebugInfoInTerminal: true,
},
}
// After
module.exports = {
logging: {
browserToTerminal: true,
},
}
```
The new `logging.browserToTerminal` option supports the log level values (`true`, `'warn'`, `'error'`). Note that the object configuration options (`depthLimit`, `edgeLimit`, `showSourceLocation`) are no longer available in the new configuration.
| Version | Changes |
| --------- | ---------------------------------------------------- |
| `v15.4.0` | experimental `browserDebugInfoInTerminal` introduced |
| `v16.2.x` | Moved to stable as `logging.browserToTerminal` |
--- ---
title: logging title: logging
description: Configure logging behavior in the terminal when running Next.js in development mode. description: 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.
--- ---
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} {/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
## Options ## Options
<AppOnly>
### Fetching ### Fetching
You can configure the logging level and whether the full URL is logged to the console when running Next.js in development mode. You can configure the logging level and whether the full URL is logged to the console when running Next.js in development mode.
...@@ -52,6 +54,8 @@ POST / ...@@ -52,6 +54,8 @@ POST /
└─ ƒ myAction(arg1, arg2) in 5ms app/actions.ts └─ ƒ myAction(arg1, arg2) in 5ms app/actions.ts
``` ```
</AppOnly>
### Incoming Requests ### 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. 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.
...@@ -112,6 +116,8 @@ module.exports = { ...@@ -112,6 +116,8 @@ module.exports = {
When enabled, browser logs include source location information (file path and line number) by default. For example: When enabled, browser logs include source location information (file path and line number) by default. For example:
<AppOnly>
```tsx filename="app/page.tsx" highlight={8} ```tsx filename="app/page.tsx" highlight={8}
'use client' 'use client'
...@@ -135,6 +141,33 @@ Clicking the button prints this message to the terminal: ...@@ -135,6 +141,33 @@ Clicking the button prints this message to the terminal:
[browser] Hello World (app/page.tsx:8:17) [browser] Hello World (app/page.tsx:8:17)
``` ```
</AppOnly>
<PagesOnly>
```tsx filename="pages/index.tsx" highlight={6}
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:
```bash filename="Terminal"
[browser] Hello World (pages/index.tsx:6:17)
```
</PagesOnly>
### Disabling Logging ### Disabling Logging
In addition, you can disable the development logging by setting `logging` to `false`. In addition, you can disable the development logging by setting `logging` to `false`.
...@@ -144,3 +177,13 @@ module.exports = { ...@@ -144,3 +177,13 @@ module.exports = {
logging: false, logging: false,
} }
``` ```
## Version History
| Version | Changes |
| --------- | -------------------------------------------------------------------------------- |
| `v16.2.0` | `browserToTerminal` added (moved from `experimental.browserDebugInfoInTerminal`) |
| `v15.4.0` | `experimental.browserDebugInfoInTerminal` introduced |
| `v15.2.0` | `incomingRequests` added |
| `v15.0.0` | `logging: false` option added, `fetches.hmrRefreshes` added for App Router |
| `v14.0.0` | `logging.fetches` moved to stable for App Router |
---
title: logging
description: Configure logging behavior in the terminal when running Next.js in development mode.
source: app/api-reference/config/next-config-js/logging
---
{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment