Speedy99 Speedy99 - 2 years ago 164
Python Question

logging request urls in django

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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download