skillfed

drf-api-logger

The production standard for DRF API observability: request/response logging, profiling, masking, and admin analytics.

drf-api-logger v1.4.0 86.3K downloads/30d#13,872 on PyPI344
Permissive license Apache-2.0 Active released

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-logger

uv

uv add drf-api-logger

poetry

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 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

Framework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Operating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python Modules

Tags

django rest framework api loggingdrf request response loggingapi observability djangosensitive data masking middlewaredjango api profilingrequest logging with admin dashboardasynchronous api logging
django-middlewareapi-observabilityrequest-logging

More Python Modules packages

idna

Converts domain names between Unicode and…

permissive · top 100 on PyPI

setuptools

Setuptools is a Python build backend and…

permissive · top 100 on PyPI

PyYAML

PyYAML parses and emits YAML 1.1 data format,…

permissive · top 100 on PyPI

pydantic

Pydantic validates Python data structures…

permissive · top 100 on PyPI

annotated-types

Provides reusable metadata objects for use with…

permissive · top 100 on PyPI

typing-inspection

Provides runtime tools to inspect and…

permissive · top 100 on PyPI

django-easy-audit

Logs every CRUD operation, authentication…

copyleft · top 15,000 on PyPI

django-request-logging

A Django middleware that logs HTTP request and…

permissive · top 15,000 on PyPI

drf-exceptions-hog

Standardizes Django REST Framework exception…

permissive · top 5,000 on PyPI

django-silk

Silk intercepts and profiles HTTP requests,…

permissive · top 5,000 on PyPI

django-querycount

Django middleware that logs the number of…

permissive · top 15,000 on PyPI

django-guid

Attaches a unique correlation ID to all logs…

permissive · top 15,000 on PyPI

djangorestframework

Builds web APIs on top of Django with…

permissive · top 1,000 on PyPI

drf-standardized-errors

Converts all Django REST Framework API error…

permissive · top 15,000 on PyPI

djangorestframework-queryfields

Allows Django REST framework API clients to…

permissive · top 15,000 on PyPI

djangorestframework-api-key

Provides API key authentication and permission…

permissive · top 5,000 on PyPI