环境:
Windows 10 + PyCharm 2022.3.3 + Django version 4.2.3
via: https://docs.djangoproject.com/zh-hans/4.2/topics/logging/#configuring-logging
日志模块配置: 在settings.py 添加如下配置:
import os LOGGING = { "version": 1, "disable_existing_loggers": False, "handlers": { "console": { "class": "logging.StreamHandler", }, }, "root": { "handlers": ["console"], "level": "DEBUG", }, "loggers": { "django": { "handlers": ["console"], "level": os.getenv("DJANGO_LOG_LEVEL", "INFO"), "propagate": False, }, }, }