Skip to content

Commit ca8ac6a

Browse files
aclark4lifetimgraham
authored andcommitted
document how to enable pymongo logging using the LOGGING setting
1 parent 84d0f04 commit ca8ac6a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,28 @@ Congratulations, your project is ready to go!
183183

184184
## Troubleshooting
185185

186-
TODO
186+
### Debug logging
187+
188+
To troubleshoot MongoDB connectivity issues, you can enable [PyMongo's logging](
189+
https://pymongo.readthedocs.io/en/stable/examples/logging.html) using
190+
[Django's `LOGGING` setting](https://docs.djangoproject.com/en/stable/topics/logging/).
191+
192+
This is a minimal `LOGGING` setting that enables PyMongo's `DEBUG` logging:
193+
194+
```python
195+
LOGGING = {
196+
"version": 1,
197+
"disable_existing_loggers": False,
198+
"handlers": {
199+
"console": {
200+
"class": "logging.StreamHandler",
201+
},
202+
},
203+
"loggers": {
204+
"pymongo": {
205+
"handlers": ["console"],
206+
"level": "DEBUG",
207+
},
208+
},
209+
}
210+
```

0 commit comments

Comments
 (0)