674
674
to have all the processes log to a :class:`SocketHandler`, and have a separate
675
675
process which implements a socket server which reads from the socket and logs
676
676
to file. (If you prefer, you can dedicate one thread in one of the existing
677
processes to perform this function.) The following section documents this
678
approach in more detail and includes a working socket receiver which can be
679
used as a starting point for you to adapt in your own applications.
677
processes to perform this function.) :ref:`This section <network-logging>`
678
documents this approach in more detail and includes a working socket receiver
679
which can be used as a starting point for you to adapt in your own
681
682
If you are using a recent version of Python which includes the
682
683
:mod:`multiprocessing` module, you could write your own handler which uses the
960
961
``.1``. Each of the existing backup files is renamed to increment the suffix
961
962
(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased.
963
Obviously this example sets the log length much much too small as an extreme
964
Obviously this example sets the log length much too small as an extreme
964
965
example. You would want to set *maxBytes* to an appropriate value.
966
967
.. _zeromq-handlers:
1037
1038
:ref:`A basic logging tutorial <logging-basic-tutorial>`
1039
1040
:ref:`A more advanced logging tutorial <logging-advanced-tutorial>`
1043
An example dictionary-based configuration
1044
-----------------------------------------
1046
Below is an example of a logging configuration dictionary - it's taken from
1047
the `documentation on the Django project <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_.
1048
This dictionary is passed to :func:`~logging.config.dictConfig` to put the configuration into effect::
1052
'disable_existing_loggers': True,
1055
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
1058
'format': '%(levelname)s %(message)s'
1063
'()': 'project.logging.SpecialFilter',
1070
'class':'django.utils.log.NullHandler',
1074
'class':'logging.StreamHandler',
1075
'formatter': 'simple'
1079
'class': 'django.utils.log.AdminEmailHandler',
1080
'filters': ['special']
1085
'handlers':['null'],
1090
'handlers': ['mail_admins'],
1094
'myproject.custom': {
1095
'handlers': ['console', 'mail_admins'],
1097
'filters': ['special']
1102
For more information about this configuration, you can see the `relevant
1103
section <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_
1104
of the Django documentation.