pkaramol
pkaramol

Reputation: 19312

View log files from EC2 instances

I am deploying a python application using nginx/uwsgi on aws.

What is the best/recommended way to view the log files produced from those two modules (in /var/log/uwsgi and /var/log/nginx) as also some custom application log files e.g. in /my/app/logfiles/error.log etc?

Upvotes: 4

Views: 19563

Answers (2)

Devon Katz
Devon Katz

Reputation: 256

The absolute easiest way to view your EC2 logs without configuring additional utilities or permissions is to use native linux commands.

After you SSH onto your machine, you can use tail -n 50 -f /path/to/logfile.log to view the last 50 lines of your log file. The -f argument tells tail to keep watching the log file and print out any new entries that are made.

You can also use grep to search long or frequently changing log files for terms. Use grep '<your search string>' /path/to/logfile.log | less to find lines matching a query and page through them

Upvotes: 2

Bhavesh
Bhavesh

Reputation: 940

The best and easiest way to keep track of your logs is using Amazon CloudWatch Logs.

For an overview, read the blog post. To setup/install the CloudWatch Logs agent, read Getting Started.

Your EC2 instance will also need an IAM role allowing it to write logs.

Upvotes: 4

Related Questions