环境:

  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,
        },
    },
}

 

posted on 2023-07-24 15:06  Jack.py  阅读(86)  评论(0编辑  收藏  举报