Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #22945
Could aid #35444, #45442
Motivation
Currently, there is no built-in way to log HTTP requests handled by the Next.js web server, whether they are serving static, SSR, or API responses. This feature is often essential for monitoring and debugging production environments. The issue requests a mechanism to enable logging of HTTP requests similar to traditional access logs.
Implementation
This PR introduces a new feature to the Next.js web server: the ability to start the server with an additional
--access-log <filename>
flag. When this flag is provided, the server writes HTTP request logs to the specified file in the standard access log format, e.g.,:Example Usage
To enable access logging, start the Next.js web server with the following command:
Breakings
This PR does not introduce breaking changes. It adds a new optional feature that is backwards-compatible with existing server configurations.
Benefits