Install & Compatibility
Where this runs
tested against v0.3.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.022s · 19.3MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.4s · import 0.023s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
QueueHandler
✓ from logutils.queue import QueueHandler
This import is for the abandoned logutils library. Modern Python should use 'from logging.handlers import QueueHandler'.
QueueListener
✓ from logutils.queue import QueueListener
This import is for the abandoned logutils library. Modern Python applications typically manage queue listeners differently or use 'logging.handlers.QueueListener' (Python 3.2+).
This quickstart demonstrates how the `logutils.queue.QueueHandler` and `logutils.queue.QueueListener` *used* to be used for asynchronous logging. It is provided for historical context only. Modern Python applications should leverage the `logging.handlers.QueueHandler` and `logging.handlers.QueueListener` (available since Python 3.2), or other concurrent logging patterns, from the standard library.
import logging
from logutils.queue import QueueHandler, QueueListener
import queue
import time
# --- WARNING: This code uses the abandoned logutils library. ---
# --- It is provided for historical context only. ---
# --- Modern applications should use the standard 'logging' module. ---
# Setup a basic handler for the listener to write to
file_handler = logging.FileHandler('legacy_app.log')
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
file_handler.setFormatter(formatter)
# Create a queue for logs
log_queue = queue.Queue(-1)
# Create a QueueHandler to put messages into the queue
queue_handler = QueueHandler(log_queue)
# Create a QueueListener to pull messages from the queue and send to the file handler
# Note: QueueListener from logutils is deprecated; logging.handlers.QueueListener is preferred.
queue_listener = QueueListener(log_queue, file_handler)
# Get a logger and add the queue handler
logger = logging.getLogger('legacy_app')
logger.setLevel(logging.INFO)
logger.addHandler(queue_handler)
# Start the listener thread
queue_listener.start()
try:
logger.info('This is an info message from logutils.')
logger.warning('A warning message via logutils.')
time.sleep(0.1)
finally:
# Stop the listener gracefully
queue_listener.stop()
print('Log messages processed (check legacy_app.log if file was written).')
# In a real scenario, you'd ensure the file handler is closed properly.
# --- Modern Python Alternative Example (conceptual) ---
# from logging.handlers import QueueHandler, QueueListener
# import logging.config
# import queue
# q = queue.Queue(-1)
# queue_handler = QueueHandler(q)
# listener = QueueListener(q, logging.FileHandler('modern_app.log'))
# listener.start()
# # ... logging code ...
# listener.stop()
Debug
Known issues
breakingThe `logutils` library is abandoned and has not been updated since 2012. It may have compatibility issues or rely on Python 2.x specific behaviors when run on modern Python 3.x environments.fixDo not use `logutils` in new projects. For existing projects, migrate to Python's standard `logging` module.
affects: 0.3.5 and earlier
gotchaMany features originally provided by `logutils` (e.g., `WatchedFileHandler`, `TimedRotatingFileHandler`, `QueueHandler`) have been integrated into Python's standard `logging` module since Python 2.6 and 3.1, or `logging.handlers` since Python 3.2.fixPrefer `import logging` and `import logging.handlers` for all your logging needs. Consult the official Python documentation for `logging`.
affects: All versions of `logutils`
deprecatedThe maintainers of `logutils` are no longer active, and the project's official website is defunct. There are no ongoing security updates or bug fixes.fixRemove `logutils` from your project's dependencies and replace its functionality with equivalent features from the standard `logging` library or other actively maintained logging extensions.
affects: All versions (0.3.5 and earlier)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'logutils'
`logutils` is not part of Python's standard library and needs to be installed, or you are trying to use a feature that is now in `logging`.
fixIf you genuinely need `logutils` (highly discouraged), run `pip install logutils`. Otherwise, migrate your code to use the standard `logging` module and its submodules (e.g., `logging.handlers`).
AttributeError: module 'logging' has no attribute 'QueueHandler'
You are attempting to access `QueueHandler` directly from the `logging` module, but it resides in `logging.handlers`.
fixChange your import statement from `import logging` to `from logging.handlers import QueueHandler`. If you were trying to use `logutils.queue.QueueHandler`, migrate to `logging.handlers.QueueHandler`.
Upgrade
Version history
0.3.5latest on PyPI · released Jun 24, 2017
Audit
Dependencies
No dependency data recorded yet.
Resources
No resource links recorded.