문제 설명
X일보다 오래된 로그 파일 삭제 (Delete log files older than X days)
Python의 TimedRotatingFileHandler
를 사용하여 로그를 만들고 회전하고 있습니다. 그러나 TimedRotatingFileHandler
에서 특정 일 이후 오래된 로그를 삭제하기 위해 사용할 수 있는 내장 기능이 있는지 또는 로그를 정리하기 위해 별도의 Python 스크립트를 작성해야 하는지 궁금합니다.
참조 솔루션
방법 1:
You can pass a backupCount
parameter to do that. More info at https://docs.python.org/3/library/logging.handlers.html#timedrotatingfilehandler
(by adi、luis.parravicini)