skillfed

pytest-logger

Plugin configuring handlers for loggers from Python logging module.

pytest-logger v1.1.1 257.5K downloads/30d#8,446 on PyPI35
Permissive license MIT Active released

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-logger

uv

uv add pytest-logger

poetry

poetry add pytest-logger

Installing 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

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Testing

Tags

pytest logging plugincapture logs in pytest testspytest logger configurationtest logging outputpytest log files by logger
loggingpytest-plugintest-debugging

More Testing packages