Roll over for TimedRotatingFileHandler in python is not happening -


i have script runs every day , using timedroatinglogfilehandler of python. below excerpt code.

log = 'test.log'           # set log title filename = '/var/log/' + log handler = timedrotatingfilehandler(filename, when="d", interval=1, backupcount=45) formatter = logging.formatter('%(asctime)s : %(name)s : %(levelname)s : %(message)s',                               datefmt='%a, %d-%b-%y %h:%m:%s') handler.setformatter(formatter) logger = logging.getlogger(__name__) logger.setlevel(logging.info) logger.addhandler(handler)  logger.info("script execution started") 

i expecting new logfile test.log gets created daily , previous log moved test.log.1 , test.log.2 etc.

is assumption correct? if so, why not happening? can see yesterday's output in today's log still. yesterday's log file not moved different file expecting. using python 2.7 on suse linux machine. have checked other threads of them don't contain answers. please let me know if need more details.

you need log rollover occur. until program this, yesterday's output still in current log.

update: timedrotatingfilehandler when script runs on multiple days, while logging on multiple days. if script completes every day before end of day, better off using filehandler filename derived date.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -