[Python-checkins] r74465 - python/trunk/Doc/library/logging.rst

vinay.sajip python-checkins at python.org
Sun Aug 16 01:23:13 CEST 2009


Author: vinay.sajip
Date: Sun Aug 16 01:23:12 2009
New Revision: 74465

Log:
Added section on logging to one file from multiple processes.

Modified:
   python/trunk/Doc/library/logging.rst

Modified: python/trunk/Doc/library/logging.rst
==============================================================================
--- python/trunk/Doc/library/logging.rst	(original)
+++ python/trunk/Doc/library/logging.rst	Sun Aug 16 01:23:12 2009
@@ -1337,6 +1337,22 @@
 
 The :class:`LoggerAdapter` class was not present in previous versions.
 
+.. _multiple-processes:
+
+Logging to a single file from multiple processes
+------------------------------------------------
+
+Although logging is thread-safe, and logging to a single file from multiple
+threads in a single process *is* supported, logging to a single file from
+*multiple processes* is *not* supported, because there is no standard way to
+serialize access to a single file across multiple processes in Python. If you
+need to log to a single file from multiple processes, the best way of doing
+this is to have all the processes log to a :class:`SocketHandler`, and have a
+separate process which implements a socket server which reads from the socket
+and logs to file. (If you prefer, you can dedicate one thread in one of the
+existing processes to perform this function.) The following section documents
+this approach in more detail and includes a working socket receiver which can
+be used as a starting point for you to adapt in your own applications.
 
 .. _network-logging:
 


More information about the Python-checkins mailing list