amazon-web-servicesamazon-cloudwatchamazon-cloudwatchlogsaws-iot-greengrass

How to send logs generated within code to AWS?


I am trying to send the logs (being generated as a part of my on-premise device and the message being sent or received using devices onboarded on greengrass) to AWS.

How is it possible?

I wanted to check SDKs also but found no documentation stating how to do it online.


Solution

  • You should use a logging framework or some other abstraction so your code is not tightly coupled to AWS CloudWatch. Then you can easily change the log destination (CloudWatch, file, database) without changing your code.

    For example, let's say you're using .NET. Here is how you can configure popular .NET logging frameworks to send logs to CloudWatch. Or here is a solution for Python. I'm sure there are similar solutions in other languages/frameworks.

    If you are already generating log files, another option is to use the CloudWatch Agent to send those existing logs to CloudWatch.