Django: disable console response messages for http responses

So, we created an application with django, and it prints all these HTTP response messages to the console every time it receives a request.

[Date String] 'GET /urlpath/..blah blah ' 200 216
[Date String] 'DELETE /anotherurl/..blah blah ' 200 205 
...
..

We disabled all logger outputs. Set Debug = False. Tried 'python manage.py runningerver --verbosity 0'. I even tried changing sys.stdout to the NullDevice () class. However, we cannot disable these response messages, which slow down the server during scanning. All other messages are disabled, except for them. Any suggestions?

I understand that the internal django web server is intended only for development, and not for production, but we would like to get sufficient speed only with the development version itself (without having to go into the intricacies of django deployment for Apache / Lighttpd).

+3
source share
2 answers

The embedded development server was not designed for performance, use instead gunicorn. You can add it as an application to your Django project, and it will provide you run_gunicornwith an alternative command runserver. This is a fair bit faster and faster than the embedded development server. If you want, you can also set the logging level using --log-level. It is also fairly easy to deploy and suitable for production.

+2
source

You can enable console logging, but with this small patch you can suppress noisy lines, like

GET /urlpath/..blah blah ' 200 216
...

, HTTP = 200. " " VirtualEnv ( ) django/core/servers/basehttp.py

WSGIRequestHandler, def log_message (self, format, * args)

# Don't bother logging requests for admin images or the favicon.
if (self.path.startswith(self.admin_media_prefix)
        or self.path == '/favicon.ico'):
    return

# START ----- Don't show page requests which have run successfully
if args[1] == '200':
    return
# END ----- Don't show page requests which have run successfully

Python 2.7.3, Django 1.4.3, , : -)

+1

All Articles