For debugging purposes, I would like to use Django\'s logging mechanism to log each and every incoming request when it \"arrives\" at django-rest-framework\'s doorstep.
In new Django 2+ better to use Middleware as a callable object like this, just connect it with your project in your Middlewares section of the settings.py file (also Middleware can be a function, not only a class because it's a callable object old MiddlewareMixin now in the deprecated module of Django):
More info in docs:
https://docs.djangoproject.com/en/2.2/topics/http/middleware/#writing-your-own-middleware
class UserActivityLogMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
print(request.method) # In this string we catch request object.
response = self.get_response(request)
return response