AWS Elastic Beanstalk logging with python (django)

前端 未结 7 1933
南笙
南笙 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:38

    None of the mentioned solutions worked for me as I am running my server on Amazon Linux 2.

    The problem wasn't in the logging configuration itself but in the .log file permissions.

    This is my related logger.config file in .ebextensions:

    commands:
      01_create_log_file:
        command: 'touch /var/log/django.log'
      02_change_log_file_permissions:
        command: 'sudo chmod ugo+rwx /var/log/django.log'
    

    As you can see I had to handle the permission problem by simply giving all permissions to all users.

    This is my Django logger configuration:

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

提交回复
热议问题