pytest-logger
Plugin configuring handlers for loggers from Python logging module.
What it is and what it does
Pytest-logger extends pytest with structured logging capture for individual named loggers. Instead of pytest's built-in log capture, it lets you configure which loggers to monitor, at what level, and routes their output to both stdout (during test runs) and to separate files organized by test and logger name in a session directory. You set it up via pytest hooks in conftest.py, naming the loggers you care about and their default output levels, then control which loggers appear during a test run using command-line options like `--log foo,bar.debug`.
The plugin is useful when your code or test fixtures use Python's standard logging module and you want fine-grained control over which log streams appear in test output and where they're stored. It organizes logs by test and logger name on disk, making it easy to review detailed logs for specific tests without cluttering the main test output.
Use it for:
- Debugging test failures by reviewing per-logger log files organized by test name and logger
- Selectively enabling verbose logging for specific loggers during test runs via command-line flags
- Capturing logs from library code and fixtures without polluting the main pytest output stream
- Archiving test logs on a per-logger basis for post-test analysis and troubleshooting
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pytest-logger is a pytest plugin that configures Python logging handlers to capture and display logs from named loggers during test execution, routing output to both the terminal and per-logger files.
Yes. It has low install friction (pytest-only dependency), active maintenance, permissive MIT license, no known vulnerabilities, and solves a real problem for teams using Python logging in tests. Install it if you need structured per-logger log capture and file organization during pytest runs.
Install
pytest-logger on PyPI
pip
pip install pytest-loggeruv
uv add pytest-loggerpoetry
poetry add pytest-loggerInstalling pytest-logger
Before you install
Low install friction; depends only on pytest. Actively maintained with a recent commit (2026-04-13) and marked Production/Stable, supporting Python 3.7 through 3.12 and PyPy.
License in practice
MIT license (permissive); you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pytest-logger
# In conftest.py:
def pytest_logger_config(logger_config):
logger_config.add_loggers(['foo'], stdout_level='info')
# In test_example.py:
import logging
foo = logging.getLogger('foo')
def test_something():
foo.info('test message')
# Run: pytest -s test_example.py
Verify before relying
- Whether the plugin works with pytest versions older than those listed in classifiers
- Performance impact when capturing logs from many loggers across large test suites
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | actively maintained — 887 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 257,462/month — #8,446 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_logger-1.1.1-py2.py3-none-any.whl
Keywords: py.test, pytest, logging
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
loggerA Python logging helper that provides utilities…
unclear · top 15,000 on PyPI
pytest-catchlogA pytest plugin that automatically captures log…
permissive · top 15,000 on PyPI
pytest-pytestrailA pytest plugin that decorates test functions…
permissive · top 15,000 on PyPI
pytest-recordingA pytest plugin that records and replays HTTP…
permissive · top 5,000 on PyPI
kgbkgb intercepts and records function calls in…
permissive · top 5,000 on PyPI
pytest-mypyIntegrates mypy static type checking into…
permissive · top 15,000 on PyPI
pylint-pytestA Pylint plugin that suppresses false-positive…
permissive · top 15,000 on PyPI
pytest-loggingA pytest plugin that configures Python logging…
permissive · top 15,000 on PyPI
logfuryLogfury adds automatic method-call tracing to…
permissive · top 15,000 on PyPI
logging-treeVisualizes the hierarchy of loggers, handlers,…
permissive · top 15,000 on PyPI