flake8-logging
A Flake8 plugin that checks for issues using the standard library logging module.
What it is and what it does
flake8-logging is a Flake8 plugin that enforces logging best practices from Python's standard library documentation. It detects eight categories of logging mistakes: direct Logger instantiation instead of getLogger(), using __file__ or __cached__ instead of __name__ with getLogger(), LogRecord attribute name clashes in the extra dict, calling exception() outside exception handlers, calling error() instead of exception() within handlers, redundant exc_info arguments, using exception() with exc_info=False, and deprecated warn() calls.
The plugin integrates directly into your Flake8 workflow and flags violations with specific rule codes (LOG001 through LOG008). It's designed for teams that want to catch logging configuration and usage errors before they reach production, where misconfigured loggers can silently fail to report errors or send messages only to stderr.
Use it for:
- Catch direct Logger() instantiation that bypasses the logger tree and configuration.
- Enforce consistent logger naming with __name__ to ensure proper hierarchical organization.
- Prevent runtime KeyError crashes from LogRecord attribute name collisions in extra dicts.
- Ensure exception() is only called within exception handlers where it captures context automatically.
- Enforce clearer logging patterns by flagging redundant or contradictory exc_info arguments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Flake8 plugin that detects and flags common mistakes in Python's standard library logging module, including improper logger instantiation, incorrect getLogger() usage, LogRecord attribute clashes, and misuse of exception logging methods.
Yes. This is a focused, well-maintained Flake8 plugin with no dependencies beyond Flake8 itself, zero known vulnerabilities, and clear value for teams using Python's standard logging module. The rules target real bugs that can silently break logging in production. Install it if you use Flake8 and want to prevent common logging mistakes.
Install
flake8-logging on PyPI
pip
pip install flake8-logginguv
uv add flake8-loggingpoetry
poetry add flake8-loggingInstalling flake8-logging
Before you install
Low friction: pure Python wheel with only flake8 as a runtime dependency. Actively maintained with recent releases and no known vulnerabilities.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects with minimal obligations.
Quickstart
pip install flake8-logging
Then run flake8 on your code:
flake8 your_module.py
If you use Flake8's select setting, add 'L' to it.
Requires Python 3.9 or later and an existing Flake8 installation.
Verify before relying
- Whether the plugin auto-activates in all Flake8 configurations or only when explicitly selected.
- Performance impact when running against large codebases with many logging statements.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flake8 |
| Maintenance | actively maintained — 340 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 96,608/month — #13,204 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_logging-1.8.0-py3-none-any.whl
Keywords: flake8
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
flake8-helperProvides utility functions and base classes to…
permissive · top 15,000 on PyPI
flake8-logging-formatA flake8 extension that enforces logging best…
permissive · top 15,000 on PyPI
flake8-use-pathlibA flake8 plugin that detects uses of os and…
permissive · top 15,000 on PyPI
flake8-djangoA flake8 plugin that detects Django-specific…
copyleft · top 15,000 on PyPI
flake8-mutableA flake8 plugin that detects mutable default…
permissive · top 15,000 on PyPI
flake8-executableA Flake8 plugin that detects and reports…
copyleft · top 15,000 on PyPI
flake8-unused-argumentsA flake8 plugin that detects unused function…
permissive · top 15,000 on PyPI
vmoduleAdds glog-style verbose logging levels to…
permissive · top 15,000 on PyPI
flake8-variables-namesA flake8 extension that detects poorly named…
permissive · top 15,000 on PyPI
datadog-loggerSends Python log messages to Datadog as Events…
permissive · top 15,000 on PyPI