简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM