python - Flask - Dump exceptions to debug later -


sometimes in production 1 can experience errors raising exceptions example flask. 1 of solutions log exception using logging.exception. it's not sufficient reproduce issue.

that nice if can dump exception file debug later, explore objects. python able ? core dump ?

you can save complete stack trace file in case of exception. can create function app instance log exceptions. in example exceptions in app or sqllachemy package logged in "sample.log" file.

def log(app):      import logging     logging.handlers import rotatingfilehandler     logging import getlogger     logging._defaultformatter = logging.formatter(u"%(message)s")     file_handler.setlevel(logging.error)     file_handler = rotatingfilehandler("sample.log", maxbytes=1024*1024*10,     backupcount=100)      loggers = [app.logger, getlogger('sqlalchemy')]     logger in loggers:         logger.addhandler(file_handler) 

in init script of application after creating app instance call created function

log(app) 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -