Created
July 20, 2025 03:02
-
-
Save mavwolverine/ee529eca7f1e41f1af150249f22e5f16 to your computer and use it in GitHub Desktop.
Access logs in Next.js production build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/next/dist/server/lib/start-server.js b/node_modules/next/dist/server/lib/start-server.js | |
index ed79818..b41b07c 100644 | |
--- a/node_modules/next/dist/server/lib/start-server.js | |
+++ b/node_modules/next/dist/server/lib/start-server.js | |
@@ -39,6 +39,14 @@ const _appinfolog = require("./app-info-log"); | |
const _turbopackwarning = require("../../lib/turbopack-warning"); | |
const _trace = require("../../trace"); | |
const _ispostpone = require("./router-utils/is-postpone"); | |
+require('pino-http-print'); | |
+const _logger = require('pino-http')( | |
+ { | |
+ transport: { | |
+ target: 'pino-http-print', | |
+ }, | |
+ }, | |
+); | |
function _interop_require_default(obj) { | |
return obj && obj.__esModule ? obj : { | |
default: obj | |
@@ -133,6 +141,7 @@ async function startServer(serverOptions) { | |
throw new Error("Using a self signed certificate is only supported with `next dev`."); | |
} | |
async function requestListener(req, res) { | |
+ if (!/^(\/_next\/static|\/_next\/image|\/favicon.ico)/.test(req.url)) _logger(req, res); | |
try { | |
if (handlersPromise) { | |
await handlersPromise; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment