问题
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