A.pylogger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s - %(message)s"))
logging.getLogger().addHandler(handler)
B.pyfrom A import logger
C.pyfrom A import logger
我现在在项目中是这样使用的。之前的帖子里有人说不能这样重复引用,单独用 logger = logging.getLogger(__name__)。但是这样,logger 就需要重新配置了。所以不清楚怎么用是对的。