--- id: drf-api-logger version: "1.4.0" license: Apache-2.0 license_treatment: permissive maintenance: active --- # drf-api-logger — The production standard for DRF API observability: request/response logging, profiling, masking, and admin analytics. License: permissive · Maintenance: active · Downloads: 86.3K/mo ## 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 above — 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 pip install drf-api-logger uv add drf-api-logger poetry add drf-api-logger ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 86.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django rest framework api logging, drf request response logging, api observability django, sensitive data masking middleware, django api profiling, request logging with admin dashboard, asynchronous api logging, django-middleware, api-observability, request-logging [View on SkillFed](https://skillfed.io/packages/drf-api-logger) · [View on PyPI](https://pypi.org/project/drf-api-logger/)