Python Module logging Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 1: Line 1:
=Internal=
=Internal=
* [[Python Logging#Subjects|Python Logging]]
* [[Python Logging#Subjects|Python Logging]]
=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:
====<tt>CRITICAL</tt>====
Generated with <code>logging.critical()</code>.
====<tt>ERROR</tt>====
Generated with <code>logging.error()</code>.
====<tt>WARNING</tt>====
Generated with <code>logging.warning()</code>.
====<tt>INFO</tt>====
Generated with <code>logging.info()</code>.
====<tt>DEBUG</tt>====
Generated with <code>logging.debug()</code>.


=Logger=
=Logger=

Revision as of 04:34, 7 July 2022

Internal

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:

CRITICAL

Generated with logging.critical().

ERROR

Generated with logging.error().

WARNING

Generated with logging.warning().

INFO

Generated with logging.info().

DEBUG

Generated with logging.debug().

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