AWS Elastic Beanstalk logging with python (django)

前端 未结 7 1934
南笙
南笙 2020-12-05 02:52

How do you manage your application logs in AWS elastic beanstalk? Which file you write you application logs to?

I\'m using the following Logging configuration in my d

7条回答
  •  一生所求
    2020-12-05 03:39

    As a beginner in terms of linux permissions, it took me some time to get it to work. Summarising the above given answers the following finally worked for me:

    logging.config

    commands:
      00_create_dir:
        command: mkdir -p /var/log/app-logs
      01_change_permissions:
        command: chmod g+s /var/log/app-logs
      02_change_default_owner:
        command: setfacl -d -m g::rw /var/log/app-logs
      03_change_owner:
        command: chown wsgi:wsgi /var/log/app-logs
    

    settings.py

    LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': '/var/log/app-logs/django.log',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
    }
    

    With this I can see the logs as a separate section using 'eb logs' or within the Beanstalk environment, section "logs".

提交回复
热议问题