AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Working with Logs

You can access logs from the Amazon EC2 instances running your applications. There are several ways to do this:

  • View a snapshot of the last 100 lines of logs (also known as tail logs) in the AWS Elastic Beanstalk console.

  • Download all logs (also known as bundle logs) from the AWS Elastic Beanstalk console.

    Note

    Legacy container types and Windows container types do not support bundle logs.

  • Configure your environment to automatically publish logs to an Amazon S3 bucket.

This topic explains how to access your logs using each method.

Note

In the eu-central-1 region, accessing logs from the instances that run your applications requires an IAM role with permission to rotate logs. If you use a default instance profile, no additional configuration of the IAM role is required. If you use a custom IAM role to deploy and manage your application, you must attach a policy to the role that grants AWS Elastic Beanstalk permission to rotate logs. For more information, see Using a Custom Instance Profile.

Viewing Tail Log Snapshots in the Elastic Beanstalk Console

To take a snapshot and view tail logs in the console

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.

  2. From the AWS Elastic Beanstalk console applications page, click the name of the environment for which you want to view logs.

  3. In the navigation menu, click Logs. The Logs page lists logs you recently requested for your environment.

  4. To get the latest snapshot of the logs for your AWS Elastic Beanstalk application, click Request Logs, and then click Last 100 Lines.

    Note

    It takes several seconds to retrieve the log files. You might need to click the Refresh button to see the contents of the log files.

  5. To view the contents of the logs you requested, in the Log file column, click Download.

    A web page displays the text output of the log file snapshot.

A copy of the logs is placed in the Amazon S3 bucket associated with your application for 15 minutes and then they are deleted. You can request new logs later if necessary. Depending on whether you are using a legacy or non-legacy container, you can access these logs in one of the following locations. If you are not sure if you are using a legacy or non-legacy container, see To check if you are using a legacy container type.

  • non-legacyelasticbeanstalk-region-account id/resources/environments/logs/tail/environment ID/instance ID/

    You can find your instance ID on the Logs page as shown in the previous diagram.

    You can find your environment ID in the Server section of the Instances configuration page.

    AWS Elastic Beanstalk Logs
  • legacy — Use the RetrieveEnvironmentInfo API to retrieve the location for the tail logs. For the CLI reference for this API, see elastic-beanstalk-retrieve-environment-info. For the API reference, go to RetrieveEnvironmentInfo in the AWS Elastic Beanstalk API Reference.

Downloading Bundle Logs from the Elastic Beanstalk Console

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.

  2. From the AWS Elastic Beanstalk console applications page, click the name of the environment for which you want to view logs.

  3. In the navigation menu, click Logs. The Logs page lists logs you recently requested for your environment.

  4. To get all logs from each of the Amazon EC2 instances for your AWS Elastic Beanstalk application, click Request Logs, and then click Full Logs.

    Note

    It takes several seconds to retrieve the log files. You might need to click the Refresh button.

  5. To view the contents of the logs you requested, in the Log file column, click Download. When you are prompted, you can either open the file or save the file to view later.

    The bundle logs are compressed into a .zip file.

A copy of the logs is placed in the Amazon S3 bucket associated with your application for 15 minutes and then they are deleted. You can request new logs later if necessary. Depending on whether you are using a legacy or non-legacy container, you can access these logs in one of the following locations. If you are not sure if you are using a legacy or non-legacy container, see To check if you are using a legacy container type.

  • non-legacyelasticbeanstalk-region-account id/resources/environments/logs/tail/environment ID/instance ID/

    You can find your instance ID on the Logs page as shown in the previous diagram.

    You can find your environment ID in the Server section of the Instances configuration page.

    AWS Elastic Beanstalk Logs
  • legacy — Use the RetrieveEnvironmentInfo API to retrieve the location for the tail logs. For the CLI reference for this API, see elastic-beanstalk-retrieve-environment-info. For the API reference, go to RetrieveEnvironmentInfo in the AWS Elastic Beanstalk API Reference.

Configuring Your Environment to Publish Logs to Amazon S3

You can configure your environment so that the logs from the Amazon EC2 instances running your applications are copied by AWS Elastic Beanstalk to the Amazon S3 bucket associated with your application.

To configure your environment to publish logs to Amazon S3

  1. Open the AWS Elastic Beanstalk console at https://console.aws.amazon.com/elasticbeanstalk/.

  2. From the AWS Elastic Beanstalk console applications page, click the environment that you want to configure.

  3. In the Overview section of the environment dashboard, click Edit.

  4. On the Configuration page, click for Software Configuration in order to edit the container settings.

  5. Select Enable log file rotation to Amazon S3.

To access your logs

  1. Open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. Depending on whether you are using a legacy or non-legacy container, navigate to one of the Amazon S3 locations. If you are not sure if you are using a legacy or non-legacy container, see To check if you are using a legacy container type.

    • legacyelasticbeanstalk-region-account id/environment name/logs/instance ID/

      For instructions on accessing your instance ID, see Listing and Connecting to Server Instances.

    • non-legacyelasticbeanstalk-region-account id/resources/environments/logs/publish/environment ID/instance ID/

      For instructions on accessing your instance ID, see Listing and Connecting to Server Instances.

      You can find your environment ID in the Server section of the Instances configuration page.

      AWS Elastic Beanstalk Logs