pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.21k stars 875 forks source link

AWS Lambda integration - async logging and plugins #1574

Closed davideicardi closed 2 years ago

davideicardi commented 2 years ago

I'm a little confused on how pino should be used inside an AWS Lambda environment.

Here the questions:

  1. Can someone clarify this documentation section: https://getpino.io/#/docs/asynchronous?id=aws-lambda ?

    Asynchronous logging is disabled by default on AWS Lambda or any other environment that modifies process.stdout. If forcefully turned on, we recommend calling dest.flushSync() at the end of each function execution to avoid losing data.

For what I can see in my environment, with pino 8.6.1 and without using any special plugin, logging is actually asynchronous (sometime I miss some logs). Should I turn it off manually with sync: false?

  1. the plugin https://github.com/FormidableLabs/pino-lambda is required for AWS Lambda or it just offers some better integration with Cloudwatch (request id, trace id, ...)? Reading pino-lambda README it looks like it offers only some additional features, but it is not necessary.

I see some other issues like #1448 and #1217, but I don't understand which steps are really necessary for AWS Lambda integration to not miss logs.

thank you!

mcollina commented 2 years ago

TL;DR use https://github.com/FormidableLabs/pino-lambda.


It's possible to use pino with Lambda directly; however, you are on your own. Lambda is such a specialized runtime (they patch Node.js) that it is hard for us to support them and provide a good experience for everybody else. pino-lambda sets everything up correctly to work with Lambda.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.