My solution for the question:
Define a MemoryHandler to handle all events before defining a FileHandler .
When a FileHandler detected, set it as the target for hiding the MemoryHandler and clear it.
import logging import logging.handlers
This works for me, so I accept this as the correct answer until a more elegant answer appears.
source share