Node.js logflare logs from serverless function without vercel integration or pino. #5204
Replies: 3 comments 6 replies
-
The proper solution is to use https://vercel.com/blog/log-drains. This will allow you to effectively query your logs with ease. |
Beta Was this translation helpful? Give feedback.
-
@paulogdm Getting a logflare log-drain setup for the build step and edge network was fairly straightforward. Runtime however proved more challenging and requires to setup pino logger and pino-logflare. The entire documentation available documentation for this is here. I would give it another try if there is a working example to plug into a custom node.js function. But I was not able to get this working in a reasonable amount of time given that we do not have a lot experience with pino, or logflare. Which is why we decided after 2 hours to put the above solution into effect which took us less than 10 minutes to write and implement and does not require additional dependencies. |
Beta Was this translation helpful? Give feedback.
-
Commenting in case anyone else comes across this... Sending straight to Logflare is useful in some instances but yes when you setup a log drain you can use
I've put some examples up here: https://github.com/Logflare/next-pino-logflare-logging-example |
Beta Was this translation helpful? Give feedback.
-
We want to log from inside our serverless function execution but without going through the hoops of setting up pino and pino.logflare with streams to the vercellogflare module.
A quick and dirty logger module we came up with looks like this:
A message send to the logger module will be posted to our logflare drain given a valid logflare api key and source token.
If unsuccessful the message will be logged to the console.
This might be helpful to some of you working with the node.js runtime for serverless functions.
Beta Was this translation helpful? Give feedback.
All reactions