python logging performance comparison and options

前端 未结 3 957
无人及你
无人及你 2020-12-28 17:15

I am researching high performance logging in Python and so far have been disappointed by the performance of the python standard logging module - but there seem to be no alte

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 18:06

    If you want a better answer try to describe your problem in more detail, why you need such a huge number of messages to log? Logging was designed to record important information, especially warnings and errors, not every line you execute.

    If logging takes more than 1% of your processing time, probably you are using it wrongly and that's not logging fault.

    Second, related to performance: do not build the message before sending it to logging module (replace format % params with format command params). This is because logging does this for you, but much faster.

提交回复
热议问题