



print() only shows text on the screen and then it is gone. Logging gives us a proper record of what the program did. Every message gets a timestamp, a severity level, and a source name, and it can be saved to a file. When a 5-stage pipeline fails at 2 AM, the log file tells you exactly which stage broke and why.
This matches the whiteboard above.
1. logging (the module) → the built-in Python module we import. Think of it as the toolbox.
2. logger (the object) → an object we create from the module with logging.getLogger('name'). Each component gets its own named logger, so a message from data_ingestion never gets confused with one from model_building.
3. handler → decides WHERE the log messages go. Two kinds used here:
StreamHandler).log file (FileHandler)One logger can have multiple handlers at the same time, which is exactly what we do → every message goes to both the terminal and a file.
4. formatter → decides HOW each message looks (timestamp, logger name, level, message). The formatter is attached to the handler, and the handler is attached to the logger.