Logging, in this context, refers to a protocol. Similar to a logbook, it contains all important records about the development of events. Depending on what is to be examined, either only certain actions or events are recorded in a process, or each individual action is checked.
If you’re learning a new programming language, you’ll inevitably make some mistakes. Even if Python is understandable for those who already know programming languages like C++ or Java due to similar structures (for example the shape of the loops), each language has its own characteristics. Python, for example, represents hierarchies using indentations. If you overlook a missing space in the heat of the moment, even the simplest application won’t work. An error log indicates the corresponding line and the error “unexpected indentation” is displayed to inexperienced developers during debugging. In this case, Python logging records simple script errors and issues a message. But logging can do more than that. Developers use logging in programs for very different application areas:
- Debugging: The entire source code is checked for errors to ensure that the finished program runs smoothly.
- Finding and fixing security vulnerabilities: Possible risks are identified and eliminated.
- IT forensics: Enables you to determine the cause of critical incidents such as hacker attacks from the log file.
- IT audit: This audit determines whether data security and data integrity are ensured, compares the company’s objectives with the existing IT structures for their compatibility, and analyzes the efficiency of the programs and operating systems.
- Comparison of different versions of data sets: A comparison is possible by creating a separate log file for each run.
Logging can generate a lot of data, especially when writing a complex application with Python. Developers use Python logging to file (a log file created by the Python logging module and filled with logging information via a handler) to collect this data. It is important that the log file works asynchronously. Otherwise, logging in Python may block the execution of the script.