How can I configure Django logging to capture deployment errors when using Azure App Service deployment logs?
0 reputation · 11 Apr 2024, 08:42 UTC
When a Django application fails to start during deployment to Azure App Service, the deployment log indicates a generic failure but does not show the Python traceback. To diagnose the issue, Django’s logging must be configured so that uncaught exceptions during startup are written to the same log store that App Service reads for deployment logs. The standard logging module uses hierarchical loggers and propagates messages to parent handlers unless propagate is disabled. However, it is unclear whether the default root logger configuration in a Django project will capture startup errors and forward them to a file handler pointing at /home/LogFiles/Application/. Additionally, the deployment log files are stored under /LogFiles/Git/ and /deployments/, and it is uncertain whether adding a FileHandler to that path will make the logs visible alongside the deployment entries.
What logging configuration ensures that exceptions raised during Django’s WSGI application load are recorded in the App Service file system? Should the root logger’s level be set to DEBUG and propagate left enabled, or is a dedicated handler required? Is it necessary to point a FileHandler at /home/LogFiles/Application/ to capture Django logs together with the deployment logs?