【问题标题】:Setting Debug=False on localhost makes the app crash and there's no way to find out what the error is在 localhost 上设置 Debug=False 会使应用程序崩溃,并且无法找出错误是什么
【发布时间】:2015-07-28 16:24:45
【问题描述】:

Debug=True 更改为False 后,应用程序开始在本地主机上崩溃。而且没有办法找出导致错误的原因,因为任何地方都没有显示错误文本:浏览器中都没有,终端中也没有。而已。

顺便说一句,在setting.py 我确实有ALLOWED_HOSTS = ['*']

Django 1.8,python 2.7。

【问题讨论】:

    标签: python django


    【解决方案1】:

    把它放在你的 settings.py 中看看你的错误:

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'filters': {
            'require_debug_false': {
                '()': 'django.utils.log.RequireDebugFalse'
            }
        },
        'formatters': {
            'verbose': {
                'format': '[contactor] %(levelname)s %(asctime)s %(message)s'
            },
        },
        'handlers': {
            # Send all messages to console
            'console': {
                'level': 'DEBUG',
                'class': 'logging.StreamHandler',
            },
        },
        'loggers': {
            # This is the "catch all" logger
            '': {
                'handlers': ['console'],
                'level': 'DEBUG',
                'propagate': False,
            },
        }
    }
    

    更多关于日志配置的信息here

    另外,你可以看看这个related question

    【讨论】:

      猜你喜欢
      • 2019-09-26
      • 2022-07-28
      • 1970-01-01
      • 1970-01-01
      • 2021-05-18
      • 2021-04-04
      • 1970-01-01
      • 2021-07-12
      • 2022-12-14
      相关资源
      最近更新 更多