Rotation of a twisted log in size / with an upper limit on the total number of files?

I have a twisted server that generates log files and rotates them depending on size. If the file size of a specific file exceeds 1 MB, a new log file is created.

However, after several days of operation, the log files begin to fill up my hard drive.

Is there a way to have a common limit for log rotation? The limit can be based on the total size (for example, only 200 GB logs — anything more will be deleted) or the number of files (for example, only 1000 logs will be saved).

+4
source share
1 answer

. factory, -

#in module mymodule, file <log.py>
def my_logger():
    f = logfile.LogFile("twistd_alert.log", '/var/log/', rotateLength=1000000, maxRotatedFiles=100)
    log_observer = log.FileLogObserver(f)
    return log_observer.emit

twistd --logger=mymodule.log.logger <your_server>
+5

All Articles