From advanced logging, I am able to get debug level logs for database calls, but cannot figure out how to get request URLs logged.
# Log Django URL requests
'django.request': {
'handlers': ['console'],
'propagate': False,
'level': 'DEBUG',
},
'django': {
'handlers': ['console'],
'propagate': False,
'level': 'WARNING',
},
https://docs.djangoproject.com/en/1.9/topics/logging/ was not too helpful here. Is logging URL requests for debugging even supported?
While the current accepted answer is correct about django.request
, there have been some updates:
https://docs.djangoproject.com/en/1.11/topics/logging/#django-server
django.server
(added in Django 1.10) logger logs all requests when log level is INFO.
(note: only works with manage.py runserver - but you shouldn't be using Django log requests in production anyway; there's nginx or similar for that.)
Quick search for logging in Django source suggests there is no logging of URL hits.
The django.request
logger seems to be used only when there are errors (500) or warnings (404, etc).
You can use a custom middleware that logs all request URLs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With