On this page
article
Rotating Log Files
Configure logs that rotate by size.
Category: logging
Problem
Configure logs that rotate by size.
Solution
handler = RotatingFileHandler('app.log', maxBytes=1_000_000, backupCount=5)
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path