trace_err = traceback.format_exc().replace("\n", "\\n") # 日志转换成一行,方便基于request_id追踪 log.error(trace_err)