A simple QueueHandler
subclass implementation utilizing QueueListener
for configured handlers. This is helpful for detaching the logger handlers from the main threads, which reduces the risk of getting blocked, for example, when using slower handlers such as smtp, file, or socket handlers.
An example YAML configuration file utilizing QueueListenerHander
snippets/queue_listener_handler/logging.yaml
Just load the configuration file and start logging.
snippets/queue_listener_handler/test_logger.py
A queue object must be passed since the handler does not set a default queue implementation. Set maxsize: -1
to make the queue unlimited.
logging.handlers.queue_listener_handler