diff options
| author | Flavio Curella <flavio.curella@gmail.com> | 2015-11-06 10:19:41 -0600 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-01-11 07:35:17 -0500 |
| commit | 0bc5cd628042bf0a44df60a93085a4f991a84dfb (patch) | |
| tree | 076999e7afc4c14840a44eff6d92b0c0ba215d36 /docs | |
| parent | 3792e291e6aee9cd43a48fac33f19a6ab24920d2 (diff) | |
Fixed #25684 -- Made runserver use logging for request/response output.
Thanks andreif for the contributing to the patch.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/django-admin.txt | 8 | ||||
| -rw-r--r-- | docs/releases/1.10.txt | 30 | ||||
| -rw-r--r-- | docs/topics/logging.txt | 23 |
3 files changed, 61 insertions, 0 deletions
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 870f5dfc5c..ca21851fe5 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -827,6 +827,14 @@ with its own :ref:`runserver<staticfiles-runserver>` command. If :djadmin:`migrate` was not previously executed, the table that stores the history of migrations is created at first run of ``runserver``. +Logging of each request and response of the server is sent to the +:ref:`django-server-logger` logger. + +.. versionchanged:: 1.10 + + In older versions, log messages were written to ``sys.stderr`` instead of + being handled through Python logging. + .. django-admin-option:: --noreload Use the ``--noreload`` option to disable the use of the auto-reloader. This diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt index f3c7669d8a..830f11b66d 100644 --- a/docs/releases/1.10.txt +++ b/docs/releases/1.10.txt @@ -397,6 +397,36 @@ Dropped support for PostgreSQL 9.1 Upstream support for PostgreSQL 9.1 ends in September 2016. As a consequence, Django 1.10 sets PostgreSQL 9.2 as the minimum version it officially supports. +``runserver`` output goes through logging +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Request and response handling of the ``runserver`` command is sent to the +:ref:`django-server-logger` logger instead of to ``sys.stderr``. If you +disable Django's logging configuration or override it with your own, you'll +need to add the appropriate logging configuration if you want to see that +output:: + + 'formatters': { + 'django.server': { + '()': 'django.utils.log.ServerFormatter', + 'format': '[%(server_time)s] %(message)s', + } + }, + 'handlers': { + 'django.server': { + 'level': 'INFO', + 'class': 'logging.StreamHandler', + 'formatter': 'django.server', + }, + }, + 'loggers': { + 'django.server': { + 'handlers': ['django.server'], + 'level': 'INFO', + 'propagate': False, + } + } + Miscellaneous ~~~~~~~~~~~~~ diff --git a/docs/topics/logging.txt b/docs/topics/logging.txt index be8c278d97..407f12aaef 100644 --- a/docs/topics/logging.txt +++ b/docs/topics/logging.txt @@ -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 |
