node.jsloggingamazon-cloudwatchamazon-cloudwatchlogsbunyan

Write all logs to the console or use a log library appender?


I'm running a couple of Node services on AWS across Elastic Beanstalk and Lambdas. We use the Bunyan library and produce JSON logs. We are considering moving our logging entirely to CloudWatch. I've found two ways of pushing logs to CloudWatch:

  1. Write everything to the console using bunyan and use the built-in log streaming in both Beanstalk and Lambda to push logs to CloudWatch for me.

  2. Use a Bunyan Stream like https://github.com/mirkokiefer/bunyan-cloudwatch and push all log events directly to CloudWatch via their APIs.

Are both valid options? Is one more preferred than the other? Any plusses and minuses that I'm missing?


Solution

  • I favor the first option: Write everything to the console using bunyan.

    I think this separates concerns better than baking cloudstream into your app. Besides, bunyan-cloudwatch is not maintained.