import logging from logging.config import dictConfig from pathlib import Path import yaml with open("./app/logger.yaml", "r") as file: # 确保日志目录存在 log_dir = Path("app/logs") log_dir.mkdir(exist_ok=True) config = yaml.safe_load(file.read()) dictConfig(config) logger = logging.getLogger(__name__)