Jason Howard
Jason Howard

Reputation: 1586

Getting log files from elastic beanstalk

I'm running a django project on elastic beanstalk. If I save my django log files to a paricular folder on my ec2 instance, is it possible to also get those when I run "eb logs -a"?

If so, what file path would I need to save my logs to on my instance?

Thanks!

Upvotes: 2

Views: 4622

Answers (1)

Marcin
Marcin

Reputation: 238051

Customization of logs is generally performed by means of .ebextensions:

Amazon Linux 1 (AL1)

The EB documentation provides only information about AL1. Specifically, you can add your configuration of your custom logs to be reported by EB in two files:

  • /opt/elasticbeanstalk/tasks/taillogs.d/ - for tail logs
  • /opt/elasticbeanstalk/tasks/bundlelogs.d/ - for full logs

The link from docs have an example. But basically if your application produces some log files, you can bundle them all using the following section in your .ebextensions (example from docs):

files: 
  "/opt/elasticbeanstalk/tasks/bundlelogs.d/applogs.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/log/*.log

/var/app/current/log/*.log would need to be adjusted to your application.

Amazon Linux 2 (AL2)

Logging configuration is undocumented for AL2. But from my own dinging up, the AL2 log config folders are:

  • /opt/elasticbeanstalk/config/private/logtasks/tail - for tail logs
  • /opt/elasticbeanstalk/config/private/logtasks/bundle - for full logs

Thus, the example could be:

files: 
  "/opt/elasticbeanstalk/config/private/logtasks/bundle/applogs.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/log/*.log

Upvotes: 5

Related Questions