What is the intended audience of your program?
If you're creating a desktop application and most users can't be expected to read the logs, you should handle it for them. Not only rotating, but also deleting old ones - you don't want to fill the poor user's hard drive!
On the other hand, if the audience is experienced UNIX sysadmins, you'll have to take a different approach.
Sysadmins will need features you cannot possibly anticipate. Send them by email, write them to append-only storage, you name it. For this audience, it's best if your logging is as flexible as possible. Flexible (in UNIX) means simple - so just write to a file and consider it done.
Also, sysadmins don't want to re-learn how to do logging all over again. Even if you want to provide this kind of feature, make sure the default is reasonable within this assumption.
Finally. tdelaney raised a important point: the standard FileHandler
doesn't pay much attention to the file it's writing to. You should use a WatchedFileHandler, which was written specifically for this purpose
logrotate.d
depends on the logger closing and reopening its file pointer on each log event. I'm not sure if the standard python file logger does that. – Photometrylogging
, see the bottom of my answer – MoneybagWatchedFileHandler
. Did you meanRotatingFileHandler
? – MoneybagWatchedFileHandler
is used withlogrotate
.RotatingFileHandler
takes care of rotating the logs itself, and replaceslogrotate
. – Offshoot