Is there a CLI to tail logs from AWS Elastic Beanstalk

UPDATE: My answer keeps getting upvotes, but things have changed since 2013. It is now easier to tail EB logs—look at posit labs's answer for a simpler way to do it :-).


Original answer:

I had been struggling with this one too. The eb CLI utility does not seem to allow for tailing your application logs currently.

However, you can tail these logs by:

  1. Creating a key pair in the EC2 console (which should give you a .pem file)
  2. Linking your EB instance to this key pair (in the EB console)
  3. Finding the public DNS of your instance in the EC2 console
  4. Connecting to your instance via ssh (`ssh -i [yourpemfile.pem] ec2-user@[your.public.dns]
  5. Tailing your log file. For a Node.js application, that's tail -f /var/log/nodejs/nodejs.log. I don't know what's the equivalent for a Flask application.

(Thanks to Richard Soutar for pointing me in the right direction on this one.)


2021 Update:

Now the best way to do this might be to use AWS CLI v2:

aws logs tail $log_group_name --follow

(Note: I couldn't get this working for me because of permissions errors.)

My previous answer was:

This is now as simple as:

eb logs --stream

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-logs.html

(I realize posit lab's answer already included the --stream option but I keep skimming by that answer because I want to see all the logs, not just one group. And if my memory were better I wouldn't have to keep Googling the same question and ending up at the same place.)


You can use the -g flag to set the log group, then use --stream to stream the results. No need to ssh into a specific machine.

eb logs -g /aws/elasticbeanstalk/yourApp-env/var/log/nodejs/nodejs.log --stream