AWS Elastic Beanstalk logging with python (django)

前端 未结 7 1935
南笙
南笙 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:23

    There's a simple way that doesn't require any beanstalk configuration.

    In your django settings under LOGGING set up a handler directed to the file '/opt/python/log/{log_file_name}'. The logs can then be accessed via the beanstalk environment menu under "Logs".

    LOGGING = {
        ...,
        'handlers': {
            'logfile': {
                'level': 'DEBUG',
                'class': 'logging.handlers.RotatingFileHandler',
                'filename': '/opt/python/log/{log_file_name}',
            },
        },
        'loggers': {
            'debugger': {
                'level': 'DEBUG',
                'handlers': ['logfile'],
            'propagate': False,
        },
    }
    

    This location is stated in the documentation here:

    https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-instancelocation

提交回复
热议问题