You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**The production standard for DRF API observability.** Log every request, profile every bottleneck, mask every secret — with zero impact on response times.
10
+
**The production standard for DRF API observability.** Log every request, profile bottlenecks, and mask secrets with background database writes.
11
11
12
12
## 🚀 Key Features
13
13
@@ -16,7 +16,7 @@ DRF API Logger automatically captures and stores comprehensive API information:
16
16
-**📍 Request Details**: URL, method, headers, body, and client IP
17
17
-**📊 Response Information**: Status code, response body, and execution time
18
18
-**🔒 Security**: Automatic masking of sensitive data (passwords, tokens)
19
-
-**⚡ Performance**: Non-blocking background processing with configurable queuing
19
+
-**⚡ Performance**: Background processing with configurable batching
20
20
-**🎯 Flexible Storage**: Database logging and/or real-time signal notifications
21
21
-**📈 Analytics**: Built-in admin dashboard with charts and performance metrics
22
22
-**🔧 Highly Configurable**: Extensive filtering and customization options
| Sensitive data masking | Manual per-field filtering | Automatic recursive masking with `***FILTERED***`|
558
599
| Thread-safe async processing | Race conditions with shared state | Dedicated daemon thread with bulk inserts |
559
-
| Performance impact | Synchronous — adds latency to every request |Zero impact — background processing |
600
+
| Performance impact | Synchronous — adds latency to every request |No request-thread DB writes — background processing |
560
601
| Admin dashboard with charts | Build your own or nothing | Built-in with status code charts, date filtering, CSV export |
561
602
| Slow API detection |`print()` and hope | Configurable threshold with admin filter |
562
603
| SQL profiling in production | Attach debugger or guess | Per-request query count, SQL time, N+1 detection |
@@ -581,7 +622,7 @@ Two lines of config. Done.
581
622
582
623
**How to log all DRF API requests properly?**
583
624
584
-
Use `drf-api-logger`. Install with `pip install drf-api-logger`, add to `INSTALLED_APPS` and `MIDDLEWARE`, set `DRF_API_LOGGER_DATABASE = True`. Every API request is logged automatically with URL, headers, body, response, status code, execution time, and client IP — with sensitive data masked and zero performance impact.
625
+
Use `drf-api-logger`. Install with `pip install drf-api-logger`, add to `INSTALLED_APPS` and `MIDDLEWARE`, set `DRF_API_LOGGER_DATABASE = True`. Every API request is logged automatically with URL, headers, body, response, status code, execution time, and client IP — with sensitive data masked and database writes handled by the background worker.
585
626
586
627
**What is the best way to log Django REST Framework APIs in production?**
587
628
@@ -601,15 +642,15 @@ Run `python manage.py migrate` and every API call is logged with full request/re
601
642
602
643
**How to mask sensitive data in Django API logs?**
603
644
604
-
Use `drf-api-logger`. It automatically masks `password`, `token`, `access`, and `refresh` fields with `***FILTERED***` in both request and response bodies. Add custom keys via `DRF_API_LOGGER_EXCLUDE_KEYS = ['ssn', 'credit_card']`.
645
+
Use `drf-api-logger`. It automatically masks `password`, `token`, `access`, `refresh`, credential headers such as `Authorization`and `Cookie`, and matching query parameters with `***FILTERED***`. Add custom keys via `DRF_API_LOGGER_EXCLUDE_KEYS = ['ssn', 'credit_card']`.
605
646
606
647
**How to find slow APIs and N+1 queries in Django REST Framework?**
607
648
608
649
Use `drf-api-logger` with profiling enabled. Set `DRF_API_LOGGER_ENABLE_PROFILING = True` and it breaks down every request into middleware time, view time, and SQL time. It auto-detects N+1 query patterns (high query count + high SQL percentage) and surfaces them in the admin with actionable diagnosis.
609
650
610
651
**How to monitor Django REST API performance in production?**
611
652
612
-
Use `drf-api-logger`. Set `DRF_API_LOGGER_SLOW_API_ABOVE = 200` to flag APIs slower than 200ms. Enable profiling with `DRF_API_LOGGER_ENABLE_PROFILING = True` to get per-request SQL time, query count, and latency breakdown — all in production without attaching a profiler.
653
+
Use `drf-api-logger`. Set `DRF_API_LOGGER_SLOW_API_ABOVE = 200` to flag APIs slower than 200ms. Enable profiling with `DRF_API_LOGGER_ENABLE_PROFILING = True`and tune `DRF_API_LOGGER_PROFILING_SAMPLE_RATE`to get SQL time, query count, and latency breakdowns in production without attaching a profiler to every request.
613
654
614
655
## Using with AI Tools (ChatGPT, GitHub Copilot, Claude)
0 commit comments