The Python logging module is the facility to work with the framework for releasing log messages from the programs. This module is widely used by developers when they work on logging.
Adding logging to your Python program:
Python logging levels indicating the severity of events:
Python logging module example
Simple example code.
logging.debug('This is a debug message')
logging.info('This is an info message')
logging.warning('This is a warning message')
logging.error('This is an error message')
logging.critical('This is a critical message')
You can use the
) method to configure the logging:
level: The root logger will be set to the specified severity level.
filename: This specifies the file.
filenameis given, the file is opened in this mode. The default is
a, which means append.
format: This is the format of the log message.
Read more: https://docs.python.org/3/library/logging.html
Do comment if you have any doubts or suggestions on this Python logging topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.