log4mongo / log4mongo-python

python logging handler for mongo database
http://log4mongo.org
Other
111 stars 37 forks source link

General question #49

Closed john012343210 closed 3 years ago

john012343210 commented 3 years ago

Hi. I have some experience in MongoDB

Since Atlas provides some free cluster, I am looking for some correct way that logs to the database. However, does MongoDB suitable for storing logs from python? Also due to the write lock contention, how could I solve this issue when using your library?

Thanks! I love python. I love logging. I love mongodb.

oz123 commented 3 years ago

To avoid a lot of writes to mongodb you can use BufferedMongoHandler which is made exactly for this purpose. Being buffered it means it writes in bulk after a certain delay.:

This subclass aims to provide buffering mechanism to avoid hammering the database server and write-locking the database too often (even if mongo is performant in that matter).

From the documentation of the subclass. I hope this helps you.