Warning() Method Of Logger Class

Method Name:



Method Signature:

warning(logMessage, *args, **kwargs)


Method Overview:

  • warning() method is used to log messages of severity level logging.WARNING.


  • The warning log messages may or may not point to something wrong, but generally set the tone that some event has happened against the normal course.


  • Examples for warning messages include resource depletion such as disk space usage reaching a high threshold, CPU temperature reaching the maximum threshold, password strength is low and so on.


  • Note that logging.WARNING is the default log level set in a Python Environment


  • The log message is composed of several parameters taken from *args and **kwargs as explained in the debug() method of logger class.



import logging


logr = logging.getLogger(__name__)

print("Log level-numeric code:")



# Set a standard log prefix

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



logr.warning("A sample warning message")



Log level-numeric code:


2017-03-25 03:19:34,954 logr3.py => A sample warning message

Copyright 2023 © pythontic.com