Registry / web-framework / drf-api-logger

drf-api-logger

JSON →
library1.2.2pypypiunverified

An API Logger for Django Rest Framework that logs request/response details (headers, body, status, timing) to the database. Provides an admin panel to view and filter logs. v1.2.0 (2025-01) adds profiling for per-request latency breakdown. Release cadence: irregular, multiple minor releases per year.

pip install drf-api-logger
INSTALL
IMPORT
SIG · DRF-API-LOGGER
D
drf-api-logger
web-frameworkpythonv1.2.2
Install
3.9s avg
Import
Disk
72MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 72.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.000s · 73MB
72MB installed
● package 72MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DRFApiLoggerMiddleware
from drf_api_logger import DRFApiLoggerMiddleware
from drf_api_logger.middleware import DRFApiLoggerMiddleware

Add 'drf_api_logger' to INSTALLED_APPS, insert DRFApiLoggerMiddleware after CommonMiddleware, then migrate. The logs are viewable at /admin/drf_api_logger/apilogsmodel/

# settings.py INSTALLED_APPS = [ ... 'drf_api_logger', ] MIDDLEWARE = [ ... 'drf_api_logger.middleware.DRFApiLoggerMiddleware', ] DRF_API_LOGGER_DATABASE = True # defaults to True DRF_API_LOGGER_SLOW_API_ABOVE = 200 # ms, optional DRF_API_LOGGER_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'] # Run migration after adding to INSTALLED_APPS # python manage.py migrate
Debug
Known issues
breakingIn v1.2.0, profiling data is stored in extra database columns. If you upgrade from <1.2.0, you must run migrations (may require schema changes).
fix
Run `python manage.py migrate drf_api_logger` after upgrading.
affects: <1.2.0
gotchaThe middleware logs request bodies, which can expose sensitive data. By default, it masks some commonly sensitive keys, but you must extend with DRF_API_LOGGER_SENSITIVE_DATA_MASK or set DRF_API_LOGGER_EXCLUDE_KEYS to avoid logging passwords, tokens, etc.
fix
Add `DRF_API_LOGGER_SENSITIVE_DATA_MASK = ['password', 'token', 'secret', ...]` in settings.
affects: all
gotchaStatic/media file requests may also be logged unless you configure DRF_API_LOGGER_SKIP_URLS or upgrade to v1.1.16+ which skips them by default.
fix
Upgrade to >=1.1.16 or add DRF_API_LOGGER_SKIP_URLS = ['/static/', '/media/'].
affects: <1.1.16
deprecatedIn v1.1.11 the middleware changed from `request.path` to `request.path_info`. If you have custom middleware relying on the old path, it may break.
fix
Use `request.path_info` instead of `request.path` in any custom extensions.
affects: >=1.1.11
Upgrade
Version history
1.2.2latest on PyPI · released May 23, 2026
Audit
Dependencies
djangorequiredCore framework dependency
djangorestframeworkrequiredDRF is required for the logger to intercept API calls
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
2
Resources
drf-api-logger — pip install drf-api-logger · libregistry