Replies: 3 comments 2 replies
-
I use below to log whatever I need to. Not sure if that helps
|
Beta Was this translation helpful? Give feedback.
-
@jdoig If you want to log all then you can use middleware. I use next-connect npm package for a more express like middleware style, and you can use it like so if you wish: https://www.npmjs.com/package/next-connect Create your logging middleware
In another file, create a reusable next connect instance with your middleware that you wish to have on every route
In API route, use the commonNextConnect middleware as so
Or you can do the traditional way with higher order functions on each route (I don't really like this way because it can get ugly fast)
In API each route, use withLogger as a higher order middleware function
|
Beta Was this translation helpful? Give feedback.
-
You will have to patch the next.js server to log all requests and responses: https://www.tomups.com/posts/log-nextjs-request-response-as-json/ |
Beta Was this translation helpful? Give feedback.
-
Is it possible to configure the dev server to log requests and responses?
Beta Was this translation helpful? Give feedback.
All reactions