stack trace from manage.py runserver not appearing

前端 未结 1 554
既然无缘
既然无缘 2020-12-29 06:39

Django\'s runserver command doesn\'t output a stack trace when I append --traceback --verbosity 2:

➫ python manage.py runserver --t         


        
相关标签:
1条回答
  • 2020-12-29 06:54

    Agreed that this is convenient, especially for MVVM-centric app development (e.g. Angular/Ember front-end). Also this is helpful when others are testing out the front-end.

    As you mentioned, this isn't provided by DEBUG=True. You can add a stacktrace when running ./manage.py runserver by adding the following to the settings.py file:

    LOGGING = {
        'version': 1,
        'handlers': {
            'console': {
                'level': 'DEBUG',
                'class': 'logging.StreamHandler',
            },
        },
        'loggers': {
            'django.request': {
                'handlers': ['console'],
                'propagate': True,
                'level': 'DEBUG',
            },
        },
    }
    

    This syntax comes from the Django documentation Configuring Logging and can be further modified to increase or decrease the amount of console-logging.

    Also note that 5XX responses are raised as ERROR messages and 4XX responses are raised as WARNING messages.

    0 讨论(0)
提交回复
热议问题