import logging log_file = 'logs/task.log' logging.basicConfig(level=logging.INFO, format='%(message)s',datefmt='%Y-%m-%d %H:%M:%S', filename=log_file, filemode='a+') logging.info('服务已启动')