Is there any way to configure buffer for logging module in Python

我与影子孤独终老i 提交于 2021-02-10 20:31:30

问题


I have verbose logging and it looks like it is significantly impacting the performance of my Python program. From what I've understood, it seems that by default, the Python logging module will buffer until one log message. Is it possible to configure this buffer for several log messages? For example, can I make the Python logging module buffer up to 10 messages? I have gone through the Python documentation and also stack overflow questions like this, this and this but there is no clear answer and therefore posting this.

Thank you for any input.


回答1:


Use the MemoryHandler. It does exactly what you want. It buffers messages until some criteria are met and then sends them to another handler to be handled.



来源:https://stackoverflow.com/questions/58453004/is-there-any-way-to-configure-buffer-for-logging-module-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!