Logging Modules

logging.handlers

Adds specialized logging destinations and buffering strategies, such as rotating files, memory buffers and queues. QueueHandler separates record submission from processing; a QueueListener can consume queued records. Network handlers require additional transport and confidentiality review.

Formal Syntax & Structure

python syntaxpython
import logging.handlers

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
import loggingfrom logging.handlers import QueueHandlerfrom queue import Queuequeue = Queue()logger = logging.Logger("demo", logging.INFO)logger.addHandler(QueueHandler(queue))logger.info("ready")print(queue.get_nowait().getMessage())
Python Reference