4π
I ran into this issue myself some time ago. Here is what happens:
-
500
errors are only logged if they are the result of an uncaught exception. If you set a500
status manually then it will not be logged. Hereβs the relevant part of the code β as you can see that piece of logging happens inside ahandle_uncaught_exception
method. -
The behaviour for
404
responses is currently the same β only uncaughtHttp404
responses are logged. However, this has changed in Django 1.10. See my comment on this ticket:I just want to note that this change has altered the behaviour of Djangoβs 404 logging somewhat.
Previously, Django would only log a 404 if a
Http404
exception bubbled up to the core handler (and not if a view/middleware caught the exception and returned a response, regardless of whether that response was still a 404).Now, it will log all 404 responses regardless of how they were generated. This seems better to me but there may be applications that were relying on the previous behaviour.
So from Django 1.10 onwards all
404
responses will get logged. It seems a bit inconsistent to me. -
Other
4xx
responses are only logged if the corresponding exception is raised.400
exceptions are logged todjango.security
and not todjango.request.
To answer your other question β what is the best way to consistently log this stuff? β the most reliable approach I have found is to write your own middleware which checks the status of all responses and does its own logging.
Edit: Iβve created a ticket that tries to address some of these inconsistencies in Django. The issue is fixed in Django 2.1.
-1π
If you only need to see the errors and you are using apache2.4 server, you can find it at /var/log/apache2/error.log
The access log can be found at /var/log/apache2/access.log
- [Django]-How to update django template variable without reloading page (AJAX)?
- [Django]-Dynamically updating values of a field depending on the choice selected in another field in Django
- [Django]-Pagination doesn't accept dict as data β unhashable type