Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsPython logging is built from four parts: loggers create and classify events, filters apply additional decisions, handlers route records to destinations, and formatters shape their output. The event moves through these parts as a LogRecord. Understanding that route makes it easier to configure logging—and to avoid duplicate messages.
What are the four parts of Python logging?
The Python Logging HOWTO describes event information passing among loggers, handlers, filters, and formatters in a LogRecord. Each component has a distinct job:
As an Amazon Associate I earn from qualifying purchases.
- Logger: the interface your code calls to create a record and decide whether it should proceed.
- Filter: an optional rule that makes a more specific decision about a record and, in current API documentation, may modify it or return a replacement.
- Handler: the route that sends an accepted record to a destination such as a console or file.
- Formatter: the rule that turns a record into the text or other presentation emitted by a handler.
A concise mental model is: logger creates and classifies; filter refines; handler routes; formatter presents. The formatter does not choose where a record goes—that is the handler’s job. Python Logging HOWTO, Python 3.14.8 · Python logging API reference, Python 3.14.8
Free tools Windows power users keep installed
One-click scans. No signup required.
What is a logger in Python?
A logger is the object application code uses to report events with calls such as debug(), info(), warning(), error(), and critical(). It creates a LogRecord containing information about the event, applies its level and any filters attached to it, then passes qualifying records to its handlers.
#1 Best Overall
Use names that follow your package
At module scope, the common pattern is logger = logging.getLogger(__name__). Because __name__ reflects the module’s dotted name, related modules form a logger hierarchy: for example, myapp.storage is below myapp. This lets an application configure logging centrally while code in individual modules uses its own named logger. If a logger has no explicitly assigned level, its effective level can come from an ancestor. Python Logging HOWTO, Python 3.14.8
Levels classify severity
The standard levels, from least to most severe, are DEBUG, INFO, WARNING, ERROR, and CRITICAL. They express operational meaning: diagnostic detail, normal confirmation, an unexpected condition that can continue, a failed operation, or a severe condition. The root logger’s default level is WARNING, so INFO and DEBUG messages are normally excluded until configuration lowers the threshold. A logger’s level determines whether a call is enabled at its point of origin; handler levels can impose an additional threshold later. Python Logging HOWTO, Python 3.14.8
Rank #2
What does a logging handler do?
A handler sends records to an output destination. The standard library provides handlers for common destinations, including streams (often the console), disk files, rotating files, sockets, and queues. A handler can have its own severity level and filters, so one destination can receive a different subset of records from another. Python Logging HOWTO, Python 3.14.8
Choose destinations and thresholds deliberately
When an application has more than one handler, decide what each destination needs to receive and how its output should look. For example, the Logging Cookbook describes sending all severities to a file while sending errors and more severe records to the console. The important choices are the destination, severity threshold, format, and whether propagation will send the same record to another handler. Python Logging Cookbook, Python 3.10
How do Python logging filters and formatters work?
Filters refine which records pass
A filter provides a finer decision than severity alone. It may be attached to a logger or a handler. A logger filter is consulted for events logged on that logger; it is not automatically consulted for records originating from every descendant logger. A handler filter sees records that reach that handler. Current API documentation also allows filters to modify a record or return a replacement, rather than only accept or reject it. Python Logging HOWTO, Python 3.14.8 · Python logging API reference, Python 3.14.8
Formatters shape the emitted record
A formatter controls the final presentation at a handler. A format might show the severity, logger name, message, and—when useful—the time. Because formatting happens at the handler, different handlers can present the same record differently for different destinations.
How a warning travels from a module to its output
Consider a module calling logger.warning("Cache is unavailable") on a logger created with logging.getLogger(__name__). Its route is:
Recommended Free Tools
- Logger and level: the named logger creates a record and checks whether WARNING meets its effective level.
- Logger filters: filters attached to that logger can accept, reject, or—where supported—change the record.
- Handler routing: the logger offers the record to its handlers. If propagation is enabled, it also passes the record up the logger hierarchy to ancestor handlers.
- Handler checks: each handler that receives the record applies its own level and filters.
- Formatting and emission: a handler’s formatter determines the presentation, and the handler emits the result to its destination.
This trace follows the documented logging model; the actual destinations and formatting depend on the application’s configuration. Python Logging HOWTO, Python 3.14.8
Best Value
Why does Python logging print duplicate messages?
A common cause is attaching handlers at both a child logger and one of its ancestors while propagation remains enabled. The child’s record can be emitted by its own handler and then again by a handler higher in the hierarchy. The API reference notes that, in general, a handler does not need to be attached at multiple points in the logger hierarchy. Put a handler at the appropriate level, or deliberately disable propagation when a logger needs a separate route. Python logging API reference, Python 3.14.8
How should you configure logging?
Use basicConfig for a straightforward setup
For a small script or uncomplicated application, logging.basicConfig() is a quick way to configure the root logger, including its level, message format, and console or file destination. If INFO or DEBUG output is needed, set a lower threshold as part of the configuration.
Use explicit configuration for more control
Applications with named loggers, multiple handlers, or more involved routing can configure logging through objects, fileConfig(), or dictionary-based dictConfig(). The HOWTO recommends dictionary configuration for new applications and deployments, but that does not mean every application needs to move beyond basicConfig(). Choose the approach that fits the configuration’s complexity. Python Logging HOWTO, Python 3.14.8 · Python logging API reference, Python 3.14.8
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




