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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With