Difference between Logging and Print in Python
Logging in Python |
Print in Python |
---|---|
Record events and errors that occur during the execution of Python programs. | Displays the information to the console for the debugging purposes. |
Mainly used in the production environment. | Mainly for debugging. |
Some features are: Log levels, filtering, formatting, and more. | There are no good features. |
It provides different log levels such as Debug, Info, Error, Warning, and Critical. | It does not have any levels, it simply prints whatever is passed to it. |
Example: import logging; Output: Can be configured to log to different output destinations (e.g. console, file, network) |
Example: print(“Hello”) Output: Prints only on the console |
Difference between Logging and Print in Python
In Python, print and logging can be used for displaying information, but they serve different purposes. In this article, we will learn what is python logging with some examples and differences between logging and print in Python.