My objective:
I found logging.handlers.MemoryHandler class: https://docs.python.org/2/library/logging.handlers.html#memoryhandler
It partly fits my purpose. It buffers all messages and flushes them whenever an error-level message appears. But if there is no error-message, it won't log anything at all.
I want my app to still log INFOs and WARNINGs if there were no error.
What's the best way to implement that?
The way I see it you can achieve something similar by configuring two loggers.
As an example see the documentation
You can decide how to log them, same file (maybe) or separate files (my-simple.log and my-detailed.log)
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.