Fixed #19395 -- Added a simple example logging config.
Thanks ken.nelson at maclaren.com.
This commit is contained in:
parent
f46603f830
commit
69f0249d7b
|
@ -230,13 +230,40 @@ use in your project code.
|
||||||
|
|
||||||
.. _dictConfig format: http://docs.python.org/library/logging.config.html#configuration-dictionary-schema
|
.. _dictConfig format: http://docs.python.org/library/logging.config.html#configuration-dictionary-schema
|
||||||
|
|
||||||
An example
|
Examples
|
||||||
----------
|
--------
|
||||||
|
|
||||||
The full documentation for `dictConfig format`_ is the best source of
|
The full documentation for `dictConfig format`_ is the best source of
|
||||||
information about logging configuration dictionaries. However, to give
|
information about logging configuration dictionaries. However, to give
|
||||||
you a taste of what is possible, here is an example of a fairly
|
you a taste of what is possible, here are a couple examples.
|
||||||
complex logging setup, configured using :func:`logging.config.dictConfig`::
|
|
||||||
|
First, here's a simple configuration which writes all request logging from the
|
||||||
|
:ref:`django-request-logger` logger to a local file::
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'file': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'class': 'logging.FileHandler',
|
||||||
|
'filename': '/path/to/django/debug.log',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'django.request': {
|
||||||
|
'handlers': ['file'],
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'propagate': True,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
If you use this example, be sure to change the ``'filename'`` path to a
|
||||||
|
location that's writable by the user that's running the Django application.
|
||||||
|
|
||||||
|
Second, here's an example of a fairly complex logging setup, configured using
|
||||||
|
:func:`logging.config.dictConfig`::
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
|
@ -396,6 +423,8 @@ Django provides four built-in loggers.
|
||||||
``django`` is the catch-all logger. No messages are posted directly to
|
``django`` is the catch-all logger. No messages are posted directly to
|
||||||
this logger.
|
this logger.
|
||||||
|
|
||||||
|
.. _django-request-logger:
|
||||||
|
|
||||||
``django.request``
|
``django.request``
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue