Python on the AWS Beanstalk. How to snapshot custom logs?

前端 未结 3 645
太阳男子
太阳男子 2021-02-02 15:20

I\'m developing python application which works on aws beanstalk environment. For error handling and debugging proposes I write logs to custom lof file on the directory /var/logs

相关标签:
3条回答
  • 2021-02-02 16:00

    Expanding on Vadim911 (and my own comment), I solved the problem using a config file in .ebextensions. Here is the python code:

    import logging
    logging.basicConfig(filename='/opt/python/log/my.log', level=logging.DEBUG)
    

    Here is the .ebextensions config file code:

    files:
      "/opt/python/log/my.log" :
       mode: "000666"
       owner: ec2-user
       group: ec2-user
       content: |
           # Askbot log file
    

    The contents of this file (along with other log files) is available using the Logs snapshot function on the AWS elastic beanstalk console.

    0 讨论(0)
  • 2021-02-02 16:00

    If you need have ability to snapshot log files from Beanstalk management console, you should just write you log files to "/opt/python/log/" folder. Elastic beanstalk scripts use this folder for log tailing.

    0 讨论(0)
  • 2021-02-02 16:02

    By default you can see the django logs here

    /var/log/httpd/error_log
    
    0 讨论(0)
提交回复
热议问题