Critical() Method Of Logger Class

Method Name:



Method Signature:

critical(logMessage, *args, **kwargs)


Method Overview:

  • critical() method of logger class writes a log message of severity logger.CRITICAL to the stderr. stderr is typically mapped to the console.


  • The *args, **kwargs help to enrich the log message which more information like date and time, ip address of the machine, line number of the module, exception information and stack information. These optional arguments to the critical method are explained as part of logging a debug message in a Python Program.


  • Developers log messages of logger.CRITICAL to record events that are catastrophic to the further execution of the program itself.


  • Examples include Unable to write a disk, Failure to allocate a memory buffer as physical memory consumption has reached the maximum, a stack overflow and so on.



# import the logging module

import logging


# Set a log prefix for critical messages

formatString = '%(asctime)s %(filename)s %(processName)s => %(message)s'



# Get a logger with the name of current module

logr = logging.getLogger(__name__)


# Log a message with severity logging.CRITICAL

logr.critical("***Pseudo***This is a Critical Message")



2017-03-25 13:43:16,974 MainProcess => ***Pseudo***This is a Critical Message

Copyright 2023 ©