Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between logging.fatal and logging.critical?

Tags:

What is the difference between logging.fatal and logging.critical? Both seem to behave in exactly the same way in Python 3.4. Are both kept because of some kind of backwards compatibility?

like image 590
AlexC Avatar asked Jul 01 '15 19:07

AlexC


People also ask

What is the fatal in logger?

A Fatal Error Log. Describes the fatal error log, its location, and contents. The fatal error log is created when a fatal error occurs. It contains information and the state obtained at the time of the fatal error.

What is logging used for Python?

Logging is a means of tracking events that happen when some software runs. Logging is important for software developing, debugging, and running. If you don't have any logging record and your program crashes, there are very few chances that you detect the cause of the problem.

What is logging basic config?

The basicConfig configures the root logger. It does basic configuration for the logging system by creating a stream handler with a default formatter. The debug , info , warning , error and critical call basicConfig automatically if no handlers are defined for the root logger.


2 Answers

logging.FATAL has been equal to logging.CRITICAL from the very first commit of the logging package to the Python repository.

It is there for compatibility reasons; the Java log4j package (which was one of the key influencers for this module) uses FATAL as the highest level, but Python felt the name CRITICAL better reflected the situation.

See PEP 282 A Logging System, the Python Enhancement Proposal that added the logging package to Python:

The term CRITICAL is used in preference to FATAL, which is used by log4j. The levels are conceptually the same - that of a serious, or very serious, error. However, FATAL implies death, which in Python implies a raised and uncaught exception, traceback, and exit. Since the logging module does not enforce such an outcome from a FATAL-level log entry, it makes sense to use CRITICAL in preference to FATAL.

like image 103
Martijn Pieters Avatar answered Sep 22 '22 17:09

Martijn Pieters


There is not a different between FATAL and CRITICAL. They have the same value:

import logging

print logging.FATAL
print logging.CRITICAL

Outputs:

50
50

PEP-282 explains the terminology:

The term CRITICAL is used in preference to FATAL, which is used by log4j. The levels are conceptually the same - that of a serious, or very serious, error. However, FATAL implies death, which in Python implies a raised and uncaught exception, traceback, and exit. Since the logging module does not enforce such an outcome from a FATAL-level log entry, it makes sense to use CRITICAL in preference to FATAL.

like image 23
Andy Avatar answered Sep 23 '22 17:09

Andy