To enable logging from the EC2 instance to CloudWatch, a logging agent needs to be installed on the EC2 instances. As an example, we will show you the logging related to a Tomcat access log file. Other log files can be handled similarly. Ensure you install this agent in your base AMI image:
- Install the AWS command client library as described in Chapter 4, in the Scripting Auto Scaling section.
- The next step is to install the logging agent itself. Since our EC2 is based on Ubuntu, the agent needs to be downloaded and installed on the EC2 instance:
- Download the CloudWatch logging agent:
- Install and configure the Cloudwatch