Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between RotatingFileHandler and logrotate.d + WatchedFileHandler for Python log rotation?

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?

like image 807
devhallo Avatar asked Mar 17 '15 16:03

devhallo


People also ask

What is a RotatingFileHandler?

RotatingFileHandler allows a log file to grow up to size N, and then immediately and automatically rotates to a new file.

What is Python logging StreamHandler?

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).

What is rotate log file?

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).


1 Answers

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.

like image 93
mbrandeis Avatar answered Sep 18 '22 20:09

mbrandeis