--- id: flake8-logging version: "1.8.0" license: MIT license_treatment: permissive maintenance: active --- # flake8-logging — A Flake8 plugin that checks for issues using the standard library logging module. License: permissive · Maintenance: active · Downloads: 96.6K/mo ## 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 above — 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 pip install flake8-logging uv add flake8-logging poetry add flake8-logging ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 96.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags flake8 logging plugin, logging code quality checks, detect logging mistakes, logger instantiation linter, logging best practices enforcement, flake8 logging rules, standard library logging linter, logging-linter, flake8-plugin, code-quality [View on SkillFed](https://skillfed.io/packages/flake8-logging) · [View on PyPI](https://pypi.org/project/flake8-logging/)