-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'logging' example is not provided; no pattern provided #119
Comments
I had a very frustrating evening yesterday trying to find a simple logging middleware example. The docs pointing nowhere was not very helpful also. I see this as a basic feature for a framework that is to be production ready and same goes for Telemetry which there is no examples to be found. |
Hey! Thanks for bringing this up. We're already working on it. 👍 |
@okbel thanks for the update 🙏🏻 . Is there any estimated date for the logging, telemetry and instrumentation examples? |
I think @leerob has offered something formidable, and it is definitely an improvement that should be included; however, for simplicity’s sake and to establish a general pattern, I’d like to see something where the log file is written on the same machine as the next instance. I’m wondering if we can squint and see the Vercel business model: if calls are processed on lambdas, there’s no local persistence and an approach like #156 makes sense :). I’d argue that for developing middleware and dev mode in general that models for local persistence be demonstrated (or, I suppose, clearly rejected in the documentation so that those considering next middleware see this limitation up front). |
This isn't a pattern we want to advocate for, whether you're running serverfull or serverless.
Next.js works open-source, on whatever infra you provide, so it's not really about Vercel's serverless infra - more so that when we talk to companies building with Next.js, they aren't persisting logs to a local file, but rather ingesting them into some logging system 👍 |
Talking about ingesting them, we are facing issues with |
We were unable to log (locally) in the middleware as The PR suggests that For us, this meant using a custom server (in docs) to get this functionality. It’s discouraged by vercel as one loses some optimizations, but I didn’t see any other way to get local logging. good news: the server code is fairly easy and the docs are solid. |
I've gone through the custom server path in the past but this time we are hosted on Vercel so we want to stay on the default setup. 😞 |
Seems like there is community desire for access to some/all of the node runtime in the middleware. Having to |
Closing as per #164 (comment) To provider more context, Middleware can be executed multiple times for the same path, and we don't have a reliable way to send logs at 1. the right time and 2. while avoiding sending it twice. The logging and analytics example have been removed until we have a more appropriate solution for it. |
Hello,
The https://nextjs.org/docs/middleware#examples page suggests that there are number of examples of various types in this repo
all point to the same resource:
https://github.com/vercel/examples/tree/main/edge-functions
Keying in on Logging, searching the Readme for the string
oggi
yields no match. Similarlyack
through the repo for/oggi/i
and you will only find a mention infeature-flag-configcat/
example. Furthermore, this is logging from a client function not from a server function e.g. the middleware function.Absent any directions, I ahem, duplicated this error vercel/next.js#13214
Further research at https://nextjs.org/docs/api-reference/edge-runtime#unsupported-apis, a leap whose connection was made my reading URL paths, suggests this is not possible. OK, I can live with that, but then it becomes all the more important that it be documented how to log server-side data in the middlewares.
I suspect most people are implementing a custom server to get
'fs'
access, a practice that seems discouraged in the docs.So is there either:
fs
and other core modules are not available (e.g.process
,util
,os
,buffer
, et al.)The text was updated successfully, but these errors were encountered: