zappa / Zappa

Serverless Python
https://zappa.ws/zappa
MIT License
3.35k stars 362 forks source link

django.server logs are not shown in CloudWatch - Using Zappa #1293

Closed sajithopensolar closed 7 months ago

sajithopensolar commented 10 months ago

My django application is running on AWS Lambda with zappa. I recently added the following to configure logs.

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "filters": {
        "require_debug_false": {
            "()": "django.utils.log.RequireDebugFalse",
        },
        "require_debug_true": {
            "()": "django.utils.log.RequireDebugTrue",
        },
        "filter_user_id": {"()": "<path_to>.UserIdFilter"},
    },
    "formatters": {
        "django.server": {
            "format": "[%(asctime)s] %(message)s user_id:%(user_id)s ",
        }
    },
    "handlers": {
        "console": {
            "level": "INFO",
            "filters": ["require_debug_true"],
            "class": "logging.StreamHandler",
        },
        "django.server": {
            "level": "INFO",
            "class": "logging.StreamHandler",
            "formatter": "django.server",
        },
    },
    "loggers": {
        "django": {
            "handlers": ["console"],
            "level": "INFO",
        },
        "django.server": {
            "handlers": ["django.server"],
            "filters": ["filter_user_id"],
            "level": "INFO",
            "propagate": False,
        },
    },
}

This is working well when I run this on docker / local server. But when I deployed this to AWS Lambda it is not showing the corresponding logs in the Cloudwatch.

Could anyone help? Thanks in advance.

SaikrishnaReddy1919 commented 10 months ago

try changing like this ("propagate" : True) :

"loggers": {
        "django": {
            "handlers": ["console"],
            "level": "INFO",
            "propagate": True
        },
        "django.server": {
            "handlers": ["django.server"],
            "filters": ["filter_user_id"],
            "level": "INFO",
            "propagate": True,
        },
    },
github-actions[bot] commented 7 months ago

Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.

github-actions[bot] commented 7 months ago

Hi there! Unfortunately, this Issue was automatically closed as it had not seen any activity in at least 100 days. If the Issue is still relevant to the latest version of Zappa, please open a new Issue.