This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
Add logger configuration to allow prod exception handling #466
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds some additional logging configuration to enable exception logging in production. Currently, when an exception or error occurs, we get unhelpful logs that look like this:
The above errors are HTTP 500 errors, but we aren't able to see any information about what is actually failing. The logging configuration in this PR ensures that:
WARNING
in productionThis does not mean that users will see the debug view that Django provides in production. When we have
DEBUG=False
, all of that will be correctly hidden. This just makes it easier for us to troubleshoot production problems (particularly ones we can't replicate locally!).I've used this config previously with great success! We also have the option to set up admin emails down the line where we'll receive an email on server errors. I think for a project of this size, that might be inadvisable and we would want a different way of aggregating/reporting errors.
Testing Instructions
Note that these steps are not to be committed and are only intended to replicate a production setup locally
DJANGO_DEBUG_ENABLED=False
inapi/env.docker
settings.py
fromif DEBUG:
toif True:
api/catalog/api/views/health_views.py
(I just addedraise ValueError("Whoops!")
above line 17)just up
just logs web
If you follow these steps and are on
main
, you should receive an HTTP 500 error page and there should be nothing printed out in the logs (or at least not an exception). However if these steps are done on this branch, you should still receive the same generic HTTP 500 page in the browser, but the logs should contain the full exception traceback.Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin