traceback.format_exc()可以打印异常日志与其他日志信息做拼接。

有个更优雅的做法:

Python 打日志有个关键字参数 exc_info=True, 会自动追加 Traceback,无需手动拼接 traceback.format_exc()

Python优雅日志打印

相关文章: