1

I have a python script that runs from an ec2 server. What is the easiest way for me to see print statements from that script? I tried viewing the system log but I don't see anything there and I can't find anything in cloudwatch. Thanks!

2 Answers 2

2

It is possible to send log of application running on EC2 to Cloudwatch directly for that you need to do following step.

  1. Create IAM Role with relevant permission and attach to Linux instance.

  2. Install the CloudWatch agent in the instances.

  3. Prepare the configuration file in the instance.

  4. Start the CloudWatch agent service in the instance.

  5. Monitor the logs using CloudWatch web console.

For your reference:- http://medium.com/tensult/to-send-linux-logs-to-aws-cloudwatch-17b3ea5f4863

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Will this show print statements? Or do I have to do a proper logging call. So far when checking the logfile it looks like it's writing, but can't find anything in aws. I get "2020-02-04 20:19:49,948 - cwlogs.push.publisher - INFO - 2812 - Thread-3 - Log group: /var/log/messages, log stream: i-0f51ba7fe5ec31f71, queue size: 0, Publish batch: {'skipped_events_count': 0....."
1

Standard output from arbitrary applications running on EC2 don't appear in CloudWatch Logs.

You can install the CloudWatch Logs Agent, configure it to collect logs from given locations, and then configure your app to log to one of those locations.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.