From ca8ac6aaf0e5db548728f2290630350dc4ce5ca1 Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Clark" Date: Wed, 20 Nov 2024 16:09:04 -0500 Subject: [PATCH] document how to enable pymongo logging using the LOGGING setting --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03e5778bd..fad0a9b42 100644 --- a/README.md +++ b/README.md @@ -183,4 +183,28 @@ Congratulations, your project is ready to go! ## Troubleshooting -TODO +### Debug logging + +To troubleshoot MongoDB connectivity issues, you can enable [PyMongo's logging]( +https://pymongo.readthedocs.io/en/stable/examples/logging.html) using +[Django's `LOGGING` setting](https://docs.djangoproject.com/en/stable/topics/logging/). + +This is a minimal `LOGGING` setting that enables PyMongo's `DEBUG` logging: + +```python +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "handlers": { + "console": { + "class": "logging.StreamHandler", + }, + }, + "loggers": { + "pymongo": { + "handlers": ["console"], + "level": "DEBUG", + }, + }, +} +```