Python has its own RotatingFileHandler
which is supposed to automatically rotate log files. As part of a linux application which would need to rotate it's log file every couple of weeks/months, I am wondering if it is any different than having a config file in logrotate.d
and using a WatchedFileHandler
instead.
Is there any difference in how they operate? Is one method safer, more efficient, or considered superior to the other?
RotatingFileHandler allows a log file to grow up to size N, and then immediately and automatically rotates to a new file.
StreamHandler. The StreamHandler class, located in the core logging package, sends logging output to streams such as sys. stdout, sys. stderr or any file-like object (or, more precisely, any object which supports write() and flush() methods).
In information technology, log rotation is an automated process used in system administration in which log files are compressed, moved (archived), renamed or deleted once they are too old or too big (there can be other metrics that can apply here).
RotatingFileHandler allows a log file to grow up to size N, and then immediately and automatically rotates to a new file.
logrotate.d runs once per day usually. If you want to limit a log file's size, logrotate.d is not the most helpful because it only runs periodically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With