python - Access Handler object to Rollover log -


how can rollover log when i've setup log using logging.config.dictconfig? can't retrieve logging.handlers.rotatingfilehandler.

import logging  import logging.config   logging.config.dictconfig({     'version': 1,     'disable_existing_loggers': false,     'handlers': {         'default': {             'class':'logging.handlers.rotatingfilehandler',             "level": "debug",             "filename": "test.log",             'backupcount': 5,             'maxbytes': 20,         },     },     'loggers': {         '': {             'handlers': ['default'],             'level': 'debug',             'propagate': true         }     } })  # how do rollover?? logging.handler[0].dorollover()  logging.info("foo") 

you can access root handlers using logging.getlogger().handlers, if have 1 might like

for h in logging.getlogger().handlers:     if type(h) == logging.handlers.rotatingfilehandler:         h.dorollover() 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -