DIY app cloud logging using AWS CloudWatch
· One min read
Need logging in your Electron app to the cloud but don't want to pay for services like Sentry, Papertrail, Bugsnag etc.?
AWS CloudWatch and Winston to the rescue!
- In your Electron
mainapp, install and setup cloudwatch-winston. - Create a log group in CloudWatch Logs
- In IAM, create a new user with only the following policy: (replace
123456789012with your AWS account ID andmy-cloudwatch-log-groupwith your desired log group name.)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:*:123456789012:log-group:my-cloudwatch-log-group",
"arn:aws:logs:*:123456789012:log-group:my-cloudwatch-log-group:log-stream:*"
]
}
]
}
- Copy the Access Key ID and Secret Acces Key and put it in
cloudwatch-winston, and start logging 🪵🔥
Now if only Winston would work in the browser we could also do this from the web and maybe even from React Native...