Getting Started With Basic Logging in Python For Beginners
Logging is a very useful tool in a programmer’s toolbox. It can help you develop a better understanding of the flow of a program and discover scenarios that you might not even have thought of while developing.
Here we will see a basic logging using python.
The Logging Module
The logging module in Python is a ready-to-use and powerful module that is designed to meet the needs of beginners as well as enterprise teams.
By default, there are 5 standard levels indicating the severity of events.
Here we will use INFO level in this logging to capture the full stack traces in an application.
$ python logging.py
This will save a log file in the same directory with ZeroDivisionError:
ERROR:root:division by zero Traceback (most recent call last): File "/home/munna/PycharmProjects/ComplexPart/loging.py", line 8, in <module> temp = a/b ZeroDivisionError: division by zero
In this way you can run any particular block of these codes.
I hope this is clear to you.