drf-api-logger
The production standard for DRF API observability: request/response logging, profiling, masking, and admin analytics.
What it is and what it does
DRF API Logger is a Django middleware that automatically captures incoming and outgoing API metadata—URL, method, headers, body, status code, client IP, and execution time—for every request handled by Django REST Framework. It masks sensitive keys like passwords and tokens with ***FILTERED***, stores logs asynchronously to avoid blocking request threads, and surfaces them in Django admin with search, filtering, charts, and optional SQL profiling. The package is designed to replace fragile custom logging middleware with a production-ready observability layer that works in both sync and async Django deployments.
The middleware can log to a database for admin visibility and analytics, emit real-time signals for custom integrations, or both. It supports request correlation via trace IDs, payload size limits to prevent unbounded storage, and optional per-endpoint policies for masking and filtering. The admin interface shows slow APIs, execution times, and profiling diagnostics when enabled, making it straightforward to identify performance bottlenecks without writing custom instrumentation.
Use it for:
- Debug slow or failing API endpoints by inspecting request/response bodies and execution times in Django admin without custom middleware.
- Mask sensitive credentials automatically across all DRF endpoints to meet compliance and security audit requirements.
- Profile SQL-heavy endpoints to detect N+1 queries and middleware overhead without adding manual instrumentation.
- Export API logs as CSV or integrate with analytics services via real-time signals for custom observability pipelines.
- Track API performance trends and anomalies using built-in admin charts and filtering by status code, method, and date range.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Captures and logs Django REST Framework API requests and responses with automatic sensitive-data masking, background storage, and Django admin analytics.
Yes. The package is actively maintained, has low install friction, carries no security vulnerabilities, and solves a real problem—comprehensive API observability without custom middleware. It's suitable for production Django REST Framework deployments that need request/response logging, sensitive-data masking, and admin analytics. The only gotcha is planning the database migration carefully on large MySQL/MariaDB tables.
Install
drf-api-logger on PyPI
pip
pip install drf-api-loggeruv
uv add drf-api-loggerpoetry
poetry add drf-api-loggerInstalling drf-api-logger
Before you install
Low friction: pure Python wheel, three runtime dependencies (Django, djangorestframework, bleach), and actively maintained with a release 37 days ago. No compiled dependencies or complex setup.
License in practice
Apache-2.0 is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install drf-api-logger
# settings.py
INSTALLED_APPS = ['drf_api_logger']
MIDDLEWARE = ['drf_api_logger.middleware.api_logger_middleware.APILoggerMiddleware']
DRF_API_LOGGER_DATABASE = True
DRF_API_LOGGER_EXCLUDE_KEYS = ['password', 'token', 'secret']
# then: python manage.py migrate
Requires Django 4.2+, Django REST Framework 3.16+, and Python 3.10+. On large MySQL/MariaDB tables, the 1.2.0+ migration adding profiling columns may require manual schema management.
Verify before relying
- Whether the background worker queue has configurable limits or backpressure handling under high request volume.
- Whether signal-based logging can coexist with database logging or if they are mutually exclusive.
- Performance overhead of profiling mode on typical production workloads.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — Django, djangorestframework, bleach |
| Maintenance | actively maintained — 37 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 86,318/month — #13,872 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: drf_api_logger-1.4.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-easy-auditLogs every CRUD operation, authentication…
copyleft · top 15,000 on PyPI
django-request-loggingA Django middleware that logs HTTP request and…
permissive · top 15,000 on PyPI
drf-exceptions-hogStandardizes Django REST Framework exception…
permissive · top 5,000 on PyPI
django-silkSilk intercepts and profiles HTTP requests,…
permissive · top 5,000 on PyPI
django-querycountDjango middleware that logs the number of…
permissive · top 15,000 on PyPI
django-guidAttaches a unique correlation ID to all logs…
permissive · top 15,000 on PyPI
djangorestframeworkBuilds web APIs on top of Django with…
permissive · top 1,000 on PyPI
drf-standardized-errorsConverts all Django REST Framework API error…
permissive · top 15,000 on PyPI
djangorestframework-queryfieldsAllows Django REST framework API clients to…
permissive · top 15,000 on PyPI
djangorestframework-api-keyProvides API key authentication and permission…
permissive · top 5,000 on PyPI