Is there a way to make the runserver command completely quiet or just display errors like 404 or 500 ?? verbosity option has no effec开发者_JAVA技巧t on it...
You can now set the verbosity with the verbosity
flag:
./manage.py runserver --verbosity 0
Documentation
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.
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,
}
精彩评论