skillfed

flake8-logging

A Flake8 plugin that checks for issues using the standard library logging module.

flake8-logging v1.8.0 96.6K downloads/30d#13,204 on PyPI86
Permissive license MIT Active released

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

uv

uv add flake8-logging

poetry

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

Development Status :: 5 - Production/StableFramework :: Flake8Intended Audience :: DevelopersNatural Language :: EnglishProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Typing :: Typed

Tags

flake8 logging pluginlogging code quality checksdetect logging mistakeslogger instantiation linterlogging best practices enforcementflake8 logging rulesstandard library logging linter
logging-linterflake8-plugincode-quality

More Quality Assurance packages