Python Logging: A meditation on silent failures
summary
Claims that logging is as essential as tests, backed by a real bug: a SequelAlchemy upgrade causes welcome emails to stop going out half the time despite a codebase with 100% test coverage. Shows concrete Python tools: the stdlib logging module, custom Formatter subclasses, and RotatingFileHandler vs TimedRotatingFileHandler (example: 20-byte max with 5 backups). Recommends structured JSON logs for ingestion by Logstash, Splunk, Papertrail or New Relic Insights, and notes logging to a database proved about 2× slower and caused performance issues.
AI-written summary · about
chapters (14)
- 0:00PYTHON LOGGING
- 0:44WHY LOGGING?
- 2:20ERRORS VS. FAILURES
- 2:49SHOULDN'T I JUST TEST MY CODE?
- 3:28DEPENDENCY CHANGES: A HORROR STORY
- 4:37WHAT IS LOGGING?
- 5:37ANATOMY OF A PYTHON LOGGER
- 5:55LOGGING LEVELS
- 6:15DEBUG INFO
- 8:02WHERE SHOULD MY LOGS GO?
- 9:22WHAT SHOULD I LOG?
- 10:28ADVANCED FORMATTING - EXTERNAL LIBRARIES - SUBCLASSING logging. Formatter
- 13:37HOW MUCH IS TOO MUCH?
- 16:39I HAVE LOGS! NOW WHAT?
related talks
29mAre logs a software engineer's best friend? Yes - follow these best practices
24mA Deep Look at Logging
30mLogging Rethought 2: The Actions of Frank Taylor Jr.
30mEffortless Logging: A deep dive into the logging module
38mLogging as a Painkiller
36mBeyond grep: Practical Logging and Metrics
27mLogs Are Good, Actually
23mTopics of Interest: Five philosophies to building better application logs
