Python Module logging Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 4: Line 4:
{{External|https://docs.python.org/3/library/logging.html#logging-levels}}
{{External|https://docs.python.org/3/library/logging.html#logging-levels}}


The logging system can be configured to filter out log messages whose logging level is under a certain threshold. The logging levels, and the corresponding logging functions are, listed from the most important to the least important, are provided below. By default, the logging system is configured to allow log messages of level WARNING and above, INFO and below are discarded.
The logging system can be configured to filter out log messages whose logging level is under a certain threshold. The logging levels, and the corresponding logging functions are, listed from the most important to the least important, are provided below. By default, the logging system is configured to allow log messages of level [[#WARNING|WARNING]] and above, [[#INFO|INFO]] and below are discarded.


====<tt>CRITICAL</tt>====
====<tt>CRITICAL</tt>====

Revision as of 04:36, 7 July 2022

Internal

Logging Levels

https://docs.python.org/3/library/logging.html#logging-levels

The logging system can be configured to filter out log messages whose logging level is under a certain threshold. The logging levels, and the corresponding logging functions are, listed from the most important to the least important, are provided below. By default, the logging system is configured to allow log messages of level WARNING and above, INFO and below are discarded.

CRITICAL

Has numeric value 50. Generated with logging.critical().

ERROR

Has numeric value 40. Generated with logging.error().

WARNING

Has numeric value 30. Generated with logging.warning().

INFO

Has numeric value 20. Generated with logging.info().

DEBUG

Has numeric value 10. Generated with logging.debug().

NOTSET

Has numeric value 0.

Logger

Logger Hierarchy

If the logger name contains dot characters, they separate levels of a hierarchy. Closer to the left, the higher the logger in the logger hierarchy: a has a higher level than a.b . Each level in the hierarchy can be given different properties. At the top of the hierarchy there's a root logger.

The root Logger

At the top of the logger hierarchy, there is a special root logger, called .

Format

The default format, without any customization is <LOGGING_LEVEL>:<logger_name>:<message>.