Week 14 • Tuesday

Block 133: Logging Best Practices

Use Python's logging module for professional script output.

Concepts

Code Examples

See exercise below.

Exercise

Add logging to yesterday's file organizer script. Log every file operation at INFO level and every error at ERROR level. Set up a logger that writes to both console and 'app.log' file.

Homework

Why is print() inadequate for production scripts? List 4 advantages of logging.