Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Log levels label how significant an event is and let you filter how much detail an application records. Log rotation solves a different problem: it limits how much log data accumulates in files and how long older files are kept. The labels and defaults below use Python’s documented logging system as a concrete example; other platforms may define them differently.

What do DEBUG, INFO, WARNING, ERROR and CRITICAL mean?

In Python’s logging system, levels progress from diagnostic detail to greater severity. The descriptions are Python’s standard meanings, not a universal contract for every language or service.

Level Python meaning Typical use
DEBUG Detailed information useful when diagnosing a problem. Record diagnostic context, such as the values or decisions needed to investigate a defect.
INFO Confirmation that things are working as expected. Record meaningful routine events, such as a service starting or a task completing.
WARNING Something unexpected happened, or a problem may arise soon, while the software continues to work as expected. Flag conditions worth attention, such as low disk space, without implying that the current operation failed.
ERROR A more serious problem prevented the software from performing a function. Record a failed operation when the application can continue running.
CRITICAL A serious error indicating that the program itself may be unable to continue. Flag an event requiring urgent attention because continued operation may be at risk.

The level is a classification of an event, not a guarantee that someone will see it. Whether a record is emitted depends on the logger and handler configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do log levels filter and route messages?

Application code creates a record at a chosen level. A logger threshold determines whether the record proceeds; handlers then send accepted records to destinations such as the console, a file, email, or a remote service. A handler can impose its own threshold, so it may discard records that passed the logger’s filter.

#1 Best Overall
Sale
Pearson Computer Networking, 8E
  • brand: Pearson
  • Computer Networking, 8e

A threshold includes records at that level and at more severe levels. For example, with a Python logger threshold of INFO, DEBUG records are filtered out while INFO, WARNING, ERROR, and CRITICAL records can proceed. A handler set to ERROR can further restrict its destination to errors and critical events.

Python’s HOWTO gives examples of routing all messages to a file, errors and more severe messages to standard output, and critical messages to email. This separation lets operators retain routine history while directing urgent events to a more visible channel. Python’s documented default threshold is WARNING, so lower-level DEBUG and INFO events are not tracked unless configuration lowers the threshold. Defaults vary by framework.

Why do applications rotate log files?

Logging levels govern event importance and filtering; rotation governs file growth and retained history. Without a rotation and retention policy, a continuously written log can consume available storage. Size-based rotation starts a new file when the active file reaches a configured limit and keeps a configured number of backup files. When that limit is reached, older backups are discarded or replaced, keeping file count and storage bounded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python provides RotatingFileHandler for size-based rotation and TimedRotatingFileHandler for time-based rotation. Size rotation is useful when a file-size ceiling is the main concern; time rotation can be more suitable when operators want calendar-aligned or regular time segments. Retention should reflect both the disk budget and how much history is useful for troubleshooting or operations. Python’s documentation does not establish one universally correct size or retention period.

Are log-level numbers interchangeable across systems?

No. Numeric values and even their ordering depend on the logging system. Python assigns increasing numbers to increasingly severe levels: DEBUG is 10, INFO 20, WARNING 30, ERROR 40, and CRITICAL 50, according to the Python 3.14 documentation. RFC 5424 syslog uses severity codes from 0 (Emergency) through 7 (Debug), with lower numbers indicating greater severity. Those scales are not directly comparable, and the RFC is an example rather than proof that every logging platform follows it.

When forwarding or translating logs, map levels by their meaning and the receiving system’s rules rather than assuming the numeric values match. Python uses the name CRITICAL; its PEP 282 explains why FATAL is not the preferred level name.

Should every failure be logged as an error?

No. Logging is not a substitute for handling a failure. Python’s guidance distinguishes ordinary command-line output, which may use print(), from error conditions that should generally raise an exception. Logging an error is appropriate when suppressing the error is intentional—for example, a long-running server records a failed request and continues serving other work. Choose the mechanism based on whether the operation should stop or the error is deliberately handled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What changes in a multi-worker application?

A rotation configuration that works for one process is not automatically safe when several worker processes write to the same file. Python’s Logging Cookbook warns against using file-based handlers directly in multi-process web applications such as those running with Gunicorn or uWSGI. Its recommended pattern is for workers to send records to a socket listener in a separate process, which handles writing. The deployment architecture should determine the logging design, rather than assuming concurrent file rotation is safe.

Sources

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.