django-request-logging
Django middleware that logs http request body.
What it is and what it does
django-request-logging is a Django middleware that intercepts HTTP requests and responses, logging their payloads with color-coded output for easier debugging. It logs request headers, body, and response content, with automatic log-level escalation for 400-599 status codes. The middleware supports fine-grained control via a @no_logging decorator for views handling sensitive data, allowing per-view configuration of what gets logged (headers, body, response, or none). It also masks sensitive headers like HTTP_AUTHORIZATION by default and respects Django's standard logging configuration.
The package is designed to work with both traditional web requests and API calls, and provides settings to customize behavior globally—including max body length (default 50000 characters), colorization, log levels, and which headers to redact. Installation requires only adding the middleware to Django's MIDDLEWARE tuple and configuring a logger for 'django.request'.
Use it for:
- Debug API requests and responses during development by viewing colored, structured logs of payloads.
- Audit HTTP traffic in staging or production by logging request/response bodies with automatic sensitive-header masking.
- Exclude logging from views handling passwords or tokens using the @no_logging decorator to prevent credential leaks.
- Troubleshoot client integration issues by examining logged request headers and response content without code changes.
- Customize log verbosity per environment—disable colorization for file logging, adjust log levels for 4xx errors.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Django middleware that logs HTTP request and response payloads with color-coded output, supporting both web and API requests with configurable detail levels and sensitive header masking.
Yes, if you are on a stable Django version and accept the maintenance risk. The package is simple, low-friction to install, has no security vulnerabilities, and solves a real debugging need. However, it is dormant (last release February 2022) and may not work with Django versions released after that date. Verify compatibility with your Django version before committing to it.
Install
django-request-logging on PyPI
pip
pip install django-request-logginguv
uv add django-request-loggingpoetry
poetry add django-request-loggingInstalling django-request-logging
Before you install
Installation is straightforward with low friction—a single runtime dependency on Django and a wheel distribution. However, the package is dormant: last release was in February 2022, with no recent commits despite the repository remaining active. Use only if you accept that bugs and compatibility issues may not be addressed.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
pip install django-request-logging
# In Django settings.py MIDDLEWARE:
MIDDLEWARE = (
'request_logging.middleware.LoggingMiddleware',
)
# Configure logging:
LOGGING = {
'loggers': {
'django.request': {
'level': 'DEBUG',
},
},
}
Requires Django to be installed and configured; middleware must be added to MIDDLEWARE tuple in settings.
Verify before relying
- Current compatibility with Django versions released after February 2022.
- Whether the package works reliably with modern Python versions beyond those tested at release.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — Django |
| Maintenance | dormant — 1,633 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 184,002/month — #10,051 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_request_logging-0.7.5-py2.py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
drf-api-loggerCaptures and logs Django REST Framework API…
permissive · top 15,000 on PyPI
django-log-request-idAttaches a unique request ID to every log…
permissive · top 15,000 on PyPI
django-log-formatter-asimFormats Django application logs in Azure…
permissive · top 15,000 on PyPI
django-cors-headersAdds Cross-Origin Resource Sharing (CORS)…
permissive · top 1,000 on PyPI
django-permissions-policySets the Permissions-Policy HTTP header on…
permissive · top 15,000 on PyPI
django-cidAssigns unique correlation IDs to incoming HTTP…
permissive · top 15,000 on PyPI
asgi-correlation-idASGI middleware that reads or generates…
permissive · top 5,000 on PyPI
django-annoyingProvides a collection of Django utility…
permissive · top 15,000 on PyPI
AutologgingAutologging provides decorators to…
permissive · top 15,000 on PyPI
django-cspDjango-CSP adds Content-Security-Policy headers…
permissive · top 5,000 on PyPI