AWS

Where Will I Find Access Logs of EC2 Instance in AWS?

AWS allows the user to create a virtual machine on the cloud by using the EC2 dashboard and using it as a server to host web applications. The user can install different servers and applications on these instances to create an infrastructure. AWS stores all the activities performed on the instances by the user inside the log file.

This guide will explain how to find access logs of the EC2 instance in AWS.

How to Find Access Logs of the EC2 Instance in AWS?

Here are the steps you need to follow for finding the access logs of the EC2 instance in AWS.

Step 1: Prerequisites

To find access logs of EC2 instances in AWS, it is required to create an EC2 instance and then select it to click on the “Connect” button:

Copy the command provided by the platform:

Paste the command on the terminal and change the path of the private key pair file:

Use the following command to install the HTTP server:

yum install httpd -y

Install Docker on the instance:

yum install docker -y

Install the Nginx server by using the following command:

yum install nginx -y

Start the HTTP services:

service httpd start

Start the Docker services:

service docker start

Start the Nginx services:

service nginx start

Step 2: Access Logs of EC2 Instance Using Commands

Head into the log directory:

cd /var/log

Find the list of files inside the log directory:

ll

Running the above command will display the list of all the files inside the log directory:

Check the logs of the instance head inside the “cloud-init-output.log” file:

nano cloud-init-output.log

The log file of the EC2 instance has been accessed:

Step 3: Access Logs of EC2 Instance Using Dashboard

Visit the instances page from the EC2 dashboard to perform the following tasks:

  • Select the instance.
  • Expand the “Actions” menu.
  • Expand the “Monitor and troubleshoot” menu from the “Actions” tab.
  • Click on the “Get system log” button:

Here comes the logs of the instance in AWS:

That’s all about how to find access logs of EC2 instances in AWS.

Conclusion

To get the logs of the EC2 instance in AWS, visit the EC2 dashboard and launch an instance from there. Connect to the instance using the command provided by the platform from the SSH section. Head into the log directory and open the “cloud-init-output.log” file to find the access logs of the instance. Log files can also be located from the EC2 dashboard and this guide has explained both the methods of finding access logs of EC2 instances.

About the author

Talha Mahmood

As a technical author, I am eager to learn about writing and technology. I have a degree in computer science which gives me a deep understanding of technical concepts and the ability to communicate them to a variety of audiences effectively.