Closed dyhe83 closed 1 year ago
I think the issue here may be with DRF_API_LOGGER_STATUS_CODES
setting.
Although readme suggests that it should be a list of strings, these strings are later being compared to DRF's status codes, which are numeric (https://www.django-rest-framework.org/api-guide/responses/#status_code) so none of them will match.
Changing the setting to DRF_API_LOGGER_STATUS_CODES = [200, 400, 404, 500]
has fixed the problem for me.
(I was also surprised that requests made using DRF's Browsable API weren't being logged - but that was on me, as only requests with "application/json"
content-type response are.)
It will log only 'ContentType application/json' in Django Rest Framework. It will log only if the request and response both are json.
Closing due to inactivity.
It will log only 'ContentType application/json' in Django Rest Framework. It will log only if the request and response both are json.
Got it, thanks!
I think the issue here may be with
DRF_API_LOGGER_STATUS_CODES
setting.Although readme suggests that it should be a list of strings, these strings are later being compared to DRF's status codes, which are numeric (https://www.django-rest-framework.org/api-guide/responses/#status_code) so none of them will match.
Changing the setting to
DRF_API_LOGGER_STATUS_CODES = [200, 400, 404, 500]
has fixed the problem for me.(I was also surprised that requests made using DRF's Browsable API weren't being logged - but that was on me, as only requests with
"application/json"
content-type response are.)
The issue here with DRF_API_LOGGER_STATUS_CODES
was the exact issue I faced. Converting these to integers instead of strings fixed this for me.
@vishalanandl177 Could you please update the docs to reflect this, as it will be very helpful for others in the future :-)
Hi,
I follow README to add app, middleware and some settings in
settings.py
.The admin panel have new page: http://localhost/admin/drf_api_logger/apilogsmodel/
But no log show up.
I called API work as expect.
Django log
I also copy the signal example code and it doesn't print anything either.
Is there anything I forget to setup??
Run
pip freeze
settings.py
as follow.