Python之日志处理(logging模块)
python之配置日志的几种方式
logging 官方高级用法
LOG_FORMAT = "%(asctime)-15s - %(levelname)-8s - %(message)s"
DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p"
logging.basicConfig(filename='run.log', level=logging.DEBUG, format=LOG_FORMAT, datefmt=DATE_FORMAT)
logging.info("API request successfully.", extra=d)
logging.error("API request error.", exc_info=True, stack_info=True, extra=d)