python logging to database

后端 未结 4 836
面向向阳花
面向向阳花 2020-12-13 02:49

I\'m seeking a way to let the python logger module to log to database and falls back to file system when the db is down.

So basically 2 things: How to let the logger

4条回答
  •  忘掉有多难
    2020-12-13 02:57

    Old question, but dropping this for others. If you want to use python logging, you can add two handlers. One for writing to file, a rotating file handler. This is robust, and can be done regardless if the dB is up or not. The other one can write to another service/module, like a pymongo integration.

    Look up logging.config on how to setup your handlers from code or json.

提交回复
热议问题