Fixed #25684 -- Made runserver use logging for request/response output.

Thanks andreif for the contributing to the patch.
This commit is contained in:
Flavio Curella 2015-11-06 10:19:41 -06:00 committed by Tim Graham
parent 3792e291e6
commit 0bc5cd6280
6 changed files with 180 additions and 48 deletions

View file

@ -484,6 +484,24 @@ Messages to this logger have the following extra context:
* ``request``: The request object that generated the logging
message.
.. _django-server-logger:
``django.server``
~~~~~~~~~~~~~~~~~
.. versionadded:: 1.10
Log messages related to the handling of requests received by the server invoked
by the :djadmin:`runserver` command. HTTP 5XX responses are logged as ``ERROR``
messages, 4XX responses are logged as ``WARNING`` messages, and everything else
is logged as ``INFO``.
Messages to this logger have the following extra context:
* ``status_code``: The HTTP response code associated with the request.
* ``request``: The request object that generated the logging message.
.. _django-template-logger:
``django.template``
@ -729,6 +747,11 @@ When :setting:`DEBUG` is ``False``:
* The ``django`` logger send messages with ``ERROR`` or ``CRITICAL`` level to
:class:`AdminEmailHandler`.
Independent of the value of :setting:`DEBUG`:
* The :ref:`django-server-logger` logger sends all messages at the ``INFO``
level or higher to the console.
.. versionchanged:: 1.9
Django's default logging configuration changed. See :ref:`the release notes