Logging in Python: Introduction
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.
Logs provide developers with an extra set of eyes that are constantly looking at the flow that an application is going through. They can store information, like which user or IP accessed the application. If an error occurs, then they can provide more insights than a stack trace by telling you what the state of the program was before it arrived at the line of code where the error occurred.
By logging useful data from the right places, you can not only debug errors easily but also use the data to analyze the performance of the application to plan for scaling or look at usage patterns to plan for marketing.
Python provides a logging system as a part of its standard library, so you can quickly add logging to your application. In this course, you’ll learn why using this module is the best way to add logging to your application as well as how to get started quickly, and you will get an introduction to some of the advanced features available.
00:00 Hi! This is Austin Cepalia with realpython.com. Today we’re going to learn about logging in Python. Logging is a very useful tool in a programmer’s toolbox.
00:10
It can help you to develop a better understanding of the flow of your program and discover scenarios that you might not have even thought of while developing. In this course, you’ll learn how to use the Python logging
module to quickly add logging to your application.
00:27 We’ll also see some of the advanced logging features Python is capable of, which will help you to design comprehensive logging systems for your Python programs.
Become a Member to join the conversation.
Reddy Kilowatt on May 11, 2024
Hello
The print function in Python 3 has many advantages over print in Python 2. That said, using a logger in a Python 3 program would throw away all of the advantages of print. Is there a simple way to take advantage of print() but capture its output to a logfile?