Is there a preferred/best-practice approach to verbose logging on the Node.js server?
Unanswered
Philippine Crocodile posted this in #help-forum
Philippine CrocodileOP
We have a ISR Next.js setup running in Google Kubernetes Engine in Google Cloud with a persistent volume serving up built static files to two client pods. Every once in awhile (once a month it seems) a situation arises where the static files build fine, but a 404 is getting returned to the web client for the static chunk being requested. We are able to monitor logs from the API backend, but the logging for the Node.js server seems quite sparse. Some info we are interested in capturing:
1. All requests to the Node.js server
2. Every time the Node.js server has to restart
3. Anytime a response is served up from any sort of Node.js-touching cache
Are there any best practices to logging
1. All requests to the Node.js server
2. Every time the Node.js server has to restart
3. Anytime a response is served up from any sort of Node.js-touching cache
Are there any best practices to logging
--verbose to stdout for the Node.js server?2 Replies
West African Lion
I don't think so. I've dug into this before and it looks like their OpenTelemetry instrumentation is the only "recommended" way to get any sort of observability out of the framework.
Let me know if you come up with any useful info, I've been looking to implement something similar.
Maybe writing a custom opentelemetry processor and using
Let me know if you come up with any useful info, I've been looking to implement something similar.
Maybe writing a custom opentelemetry processor and using
@opentelemetry/sdk-trace-node 's ConsoleSpanExporter is viable but idk much about otel.@West African Lion I don't think so. I've dug into this before and it looks like their OpenTelemetry instrumentation is the only "recommended" way to get any sort of observability out of the framework.
Let me know if you come up with any useful info, I've been looking to implement something similar.
Maybe writing a custom opentelemetry processor and using `@opentelemetry/sdk-trace-node` 's `ConsoleSpanExporter` is viable but idk much about otel.
Philippine CrocodileOP
Interesting, yeah I couldn't find anything - the official documentation just shows how to send some server logs to the web client which isn't what we want.
For now we're going to add middleware that logs an environment variable that uniquely identifies the hostname of the K8 pod, but really we're going to log every request and then narrow down what's useful moving forward.
For now we're going to add middleware that logs an environment variable that uniquely identifies the hostname of the K8 pod, but really we're going to log every request and then narrow down what's useful moving forward.