Django manage.py runserver verbosity

前端 未结 3 1671
遇见更好的自我
遇见更好的自我 2021-02-20 18:15

Is there a way to make the runserver command completely quiet or just display errors like 404 or 500 ?? verbosity option has no effect on it...

相关标签:
3条回答
  • 2021-02-20 18:52

    There is no way to make the command less verbose with options. You can however pipe the output someplace where you don't need to care about it. On Linux/OS X/*nix you can pipe the output to /dev/null with something like:

    $ ./manage.py runserver > /dev/null
    

    The equivalent on windows would be something like:

    python manage.py runserver > NUL
    

    One last note: If you are seeking to suppress the output as a matter of preference in your development environment, awesome! This should work for you. If you are seeking to do this for almost any other reason, it's probably a sign that you are using the dev server for something which you shouldn't. "./manage.py runserver" should never be used for anything other than local development.

    0 讨论(0)
  • 2021-02-20 18:53

    You can now set the verbosity with the verbosity flag:

    ./manage.py runserver --verbosity 0
    

    Documentation

    0 讨论(0)
  • 2021-02-20 18:58

    I managed to pull it off by disabling logging in general, as I am launching my application as a subprocess of different application. Documentation.

    This blocks all logs including Watching for file changes with StatReloader.

    And all logs of this kind: [31/Jul/2020 20:42:17] "GET /admin/ HTTP/1.1" 200 6641.

    By adding this to my settings.py:

    LOGGING = {
        "version": 1,
        "disable_existing_loggers": True,
    }
    
    0 讨论(0)
提交回复
热议问题