610
610
to have all the processes log to a :class:`SocketHandler`, and have a separate
611
611
process which implements a socket server which reads from the socket and logs
612
612
to file. (If you prefer, you can dedicate one thread in one of the existing
613
processes to perform this function.) The following section documents this
614
approach in more detail and includes a working socket receiver which can be
615
used as a starting point for you to adapt in your own applications.
613
processes to perform this function.) :ref:`This section <network-logging>`
614
documents this approach in more detail and includes a working socket receiver
615
which can be used as a starting point for you to adapt in your own
617
618
If you are using a recent version of Python which includes the
618
619
:mod:`multiprocessing` module, you could write your own handler which uses the
679
680
``.1``. Each of the existing backup files is renamed to increment the suffix
680
681
(``.1`` becomes ``.2``, etc.) and the ``.6`` file is erased.
682
Obviously this example sets the log length much much too small as an extreme
683
Obviously this example sets the log length much too small as an extreme
683
684
example. You would want to set *maxBytes* to an appropriate value.
686
An example dictionary-based configuration
687
-----------------------------------------
689
Below is an example of a logging configuration dictionary - it's taken from
690
the `documentation on the Django project <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_.
691
This dictionary is passed to :func:`~logging.config.dictConfig` to put the configuration into effect::
695
'disable_existing_loggers': True,
698
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
701
'format': '%(levelname)s %(message)s'
706
'()': 'project.logging.SpecialFilter',
713
'class':'django.utils.log.NullHandler',
717
'class':'logging.StreamHandler',
718
'formatter': 'simple'
722
'class': 'django.utils.log.AdminEmailHandler',
723
'filters': ['special']
733
'handlers': ['mail_admins'],
737
'myproject.custom': {
738
'handlers': ['console', 'mail_admins'],
740
'filters': ['special']
745
For more information about this configuration, you can see the `relevant
746
section <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging>`_
747
of the Django documentation.