Loading video player…

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.

Avatar image for Reddy Kilowatt

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?

Become a Member to join the conversation.