当我执行logger.info(traceback.print_exc())
,跟踪在控制台上而不是在日志文件中我有logger.propagate = False
也是同样的问题
print_exc
prints the stack trace to stderr.
Just use the exc_info=1 argument and it will automaticaly include the exception.
logging.exception("Exception") #or
logging.error("exception ",exc_info=1) #or
logging.info("Exception has occured" ,exc_info=1)
I am using python 2.7 and sadly exc_info=1
never worked for me so I had to use this:
import traceback
...
log.debug(traceback.format_exc())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.