@@ -16,6 +16,73 @@ DRF API Logger 1.2.3 supports:
1616The GitHub Actions workflow tests representative Django versions from this
1717support range before publishing package artifacts.
1818
19+ Production Doctor Command
20+ -------------------------
21+
22+ Run ``drf_api_logger_doctor `` before enabling database logging in production
23+ and after deployment changes that affect logging, storage, retention, masking,
24+ payload limits, or profiling.
25+
26+ .. code-block :: bash
27+
28+ python manage.py drf_api_logger_doctor
29+
30+ The command is read-only. It validates logging mode, database alias readiness,
31+ DRF API Logger migrations, the log table, queue settings, background worker
32+ status, payload limits, masking configuration, and profiling settings. It does
33+ not create tables, run migrations, prune rows, or inspect stored request or
34+ response payloads.
35+
36+ Use JSON output in CI or deployment checks:
37+
38+ .. code-block :: bash
39+
40+ python manage.py drf_api_logger_doctor --format json
41+
42+ Fail a deployment on warnings or errors:
43+
44+ .. code-block :: bash
45+
46+ python manage.py drf_api_logger_doctor --fail-level warning
47+ python manage.py drf_api_logger_doctor --fail-level error
48+
49+ Use ``--database `` when ``DRF_API_LOGGER_DEFAULT_DATABASE `` points to a
50+ dedicated log database and the deployment check must inspect that alias
51+ explicitly:
52+
53+ .. code-block :: bash
54+
55+ python manage.py drf_api_logger_doctor --database logs_db --format json
56+
57+ Result levels:
58+
59+ ``OK ``
60+ The checked condition is valid for the current configuration.
61+
62+ ``WARNING ``
63+ The package can run, but the setting or runtime state deserves operator
64+ attention before production use.
65+
66+ ``ERROR ``
67+ The package is likely misconfigured for the selected logging mode. Fix the
68+ issue before relying on production database logging.
69+
70+ Deployment Checklist
71+ --------------------
72+
73+ Before enabling database logging in production:
74+
75+ - Run ``python manage.py migrate drf_api_logger `` on the configured log
76+ database.
77+ - Run ``python manage.py drf_api_logger_doctor --fail-level warning ``.
78+ - Keep finite body limits with ``DRF_API_LOGGER_MAX_REQUEST_BODY_SIZE `` and
79+ ``DRF_API_LOGGER_MAX_RESPONSE_BODY_SIZE ``.
80+ - Add application-specific secrets to ``DRF_API_LOGGER_EXCLUDE_KEYS ``.
81+ - Skip health and metrics endpoints with ``DRF_API_LOGGER_SKIP_URL_NAME `` or
82+ ``DRF_API_LOGGER_SKIP_NAMESPACE ``.
83+ - Schedule ``prune_api_logs `` with a dry run first.
84+ - Monitor ``queue_backlog ``, ``dropped_count ``, and ``failed_insert_count ``.
85+
1986Database Growth
2087---------------
2188
0 commit comments