AWS Lambda logging best practices

Logging in AWS Lambda is super simple - you just print to the output and it lands in the CloudWatch. But even that can be made better or worse. Here are my tips and best practices from real-life production serverless applications. https://betterdev.blog/aws-lambda-logging-best-practices/

I like bunyan. But Winston is fine I guess.

Very informative article. Highly recommend.

Good article, thanks for sharing.

In Node, if your logger uses console.log() to write to the output, the request ID will be prepended automatically to the log messages. But if you write to the output stream directly, you need to add the request ID to the log by yourself.

I assume this refers to using process.stdout.write rather than console.log? If so, it might be worth adding something about this, as it left me wondering about the mechanics of this.

You could also incorporate this into your “best practices” example at the end of the article to omit the automatically-included INFO loglevel and timestamp.

Thank you!

Winston is just an example here, bunyan would be fine as well.

Yes, exactly. Thanks for pointing this out, I will update.

You might be interested in the logger/correlation ID features of https://github.com/getndazn/dazn-lambda-powertools - been super useful for us so far.

This is very useful info. Might come handy as we build out our Datalakehouse solution on AWS.