<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python logging from multiple processes</title>
	<atom:link href="http://www.huyng.com/archives/python-logging-from-multiple-processes/418/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/</link>
	<description></description>
	<lastBuildDate>Mon, 16 Aug 2010 10:05:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: andrew cooke</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-3196</link>
		<dc:creator>andrew cooke</dc:creator>
		<pubDate>Mon, 16 Aug 2010 10:05:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-3196</guid>
		<description>Thanks for this.  Very useful, particularly if you want logs from various machines to be in one place.  Also, I knew using twisted was going to be the right way to implement it, so now I have an example to help me learn that...</description>
		<content:encoded><![CDATA[<p>Thanks for this.  Very useful, particularly if you want logs from various machines to be in one place.  Also, I knew using twisted was going to be the right way to implement it, so now I have an example to help me learn that&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chugo</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-2180</link>
		<dc:creator>Chugo</dc:creator>
		<pubDate>Fri, 29 Jan 2010 21:29:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-2180</guid>
		<description>Hello, I&#039;m trying to run on Windows but I get this trace. Any idea where is the problem? 

Traceback (most recent call last):
  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 693, in
run

  File \D:Python25Libsite-packages	wistedscripts	wistd.py\, line 23, in ru
nApp

  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 411, in
run

  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 494, in
createOrGetApplication

---  ---
  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 505, in
getApplication

  File \D:Python25Libsite-packages	wistedapplicationservice.py\, line 390,
 in loadApplication

  File \D:Python25Libsite-packages	wistedpersistedsob.py\, line 210, in lo
adValueFromFile

  File \loggingserver.py\, line 16, in 
    import loggingprotocol
exceptions.ImportError: No module named loggingprotocol

Failed to load application: No module named loggingprotocol</description>
		<content:encoded><![CDATA[<p>Hello, I&#8217;m trying to run on Windows but I get this trace. Any idea where is the problem? </p>
<p>Traceback (most recent call last):<br />
  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 693, in<br />
run</p>
<p>  File \D:Python25Libsite-packages	wistedscripts	wistd.py\, line 23, in ru<br />
nApp</p>
<p>  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 411, in<br />
run</p>
<p>  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 494, in<br />
createOrGetApplication</p>
<p>&#8212;  &#8212;<br />
  File \D:Python25Libsite-packages	wistedapplicationapp.py\, line 505, in<br />
getApplication</p>
<p>  File \D:Python25Libsite-packages	wistedapplicationservice.py\, line 390,<br />
 in loadApplication</p>
<p>  File \D:Python25Libsite-packages	wistedpersistedsob.py\, line 210, in lo<br />
adValueFromFile</p>
<p>  File \loggingserver.py\, line 16, in<br />
    import loggingprotocol<br />
exceptions.ImportError: No module named loggingprotocol</p>
<p>Failed to load application: No module named loggingprotocol</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Huy</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-1091</link>
		<dc:creator>Huy</dc:creator>
		<pubDate>Tue, 01 Sep 2009 04:00:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-1091</guid>
		<description>Guys,
&lt;br&gt;
Thanks for the follow up... I&#039;ve actually run into conflicting updates from multiple processes before. During those times I was trying to log  a few images that were base64 encoded to strings from multiple processes. They were relatively small images, most were icons under 2kb.... However, I did get the occasional 8kb image which seems to be over the limit you&#039;ve specified?  Take a look at the script  I wrote below. It basically spawns 5 processes and tries to log 100 messages of a single number to the same log file.  Each log message should end with a line break. However, if you scroll through the test-results, you can see that some messages have been truncated because another process is trying to write to the same file at the same time. 


&lt;p&gt;&lt;b&gt;Results from code below&lt;/b&gt;&lt;/p&gt;&lt;a href=&quot;http://www.huyng.com/wp-content/uploads/logging-test.txt&quot; rel=&quot;nofollow&quot;&gt;log test results&lt;/a&gt;
&lt;br&gt;
&lt;b&gt;Multiprocess log test&lt;/b&gt;&lt;br&gt;&lt;br&gt;


&lt;pre&gt;&lt;code&gt;
#!/usr/bin/env python
import logging
logging.basicConfig(format=&#039;%(message)s&#039;, filename=&#039;loggingtest.txt&#039;)
logging.root.setLevel(logging.INFO)

from multiprocessing import Pool
def f(x):
    for i in range(100):
        logging.info(10000 * str(x) +  &quot;\n&quot;)

if __name__ == &#039;__main__&#039;:
    p = Pool(5)
    p.map(f, [1,2,3,4,5])
&lt;/code&gt;&lt;/pre&gt;


</description>
		<content:encoded><![CDATA[<p>Guys,<br />
<br />
Thanks for the follow up&#8230; I&#8217;ve actually run into conflicting updates from multiple processes before. During those times I was trying to log  a few images that were base64 encoded to strings from multiple processes. They were relatively small images, most were icons under 2kb&#8230;. However, I did get the occasional 8kb image which seems to be over the limit you&#8217;ve specified?  Take a look at the script  I wrote below. It basically spawns 5 processes and tries to log 100 messages of a single number to the same log file.  Each log message should end with a line break. However, if you scroll through the test-results, you can see that some messages have been truncated because another process is trying to write to the same file at the same time. </p>
<p><b>Results from code below</b></p>
<p><a href="http://www.huyng.com/wp-content/uploads/logging-test.txt" rel="nofollow">log test results</a><br />
<br />
<b>Multiprocess log test</b></p>
<pre><code>
#!/usr/bin/env python
import logging
logging.basicConfig(format='%(message)s', filename='loggingtest.txt')
logging.root.setLevel(logging.INFO)

from multiprocessing import Pool
def f(x):
    for i in range(100):
        logging.info(10000 * str(x) +  "\n")

if __name__ == '__main__':
    p = Pool(5)
    p.map(f, [1,2,3,4,5])
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erich Heine</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-1077</link>
		<dc:creator>Erich Heine</dc:creator>
		<pubDate>Sun, 16 Aug 2009 16:11:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-1077</guid>
		<description>Why do you need this complicated of a setup? I have never seen multiple processes have problems with loging.FileHandler, as it opens the file in mode=&quot;a&quot; and calls fd.flush() in every emit. In fact, I was recently concerned about this, so I did some tests.  My setup was very simple: 

running 3 processes, each on a different processor. Each process wrote to the log file in a loop, for some n iterations.  

I never had a problem.  If can you point me to scenarios where multiple processes actually do cause problems?</description>
		<content:encoded><![CDATA[<p>Why do you need this complicated of a setup? I have never seen multiple processes have problems with loging.FileHandler, as it opens the file in mode=&#8221;a&#8221; and calls fd.flush() in every emit. In fact, I was recently concerned about this, so I did some tests.  My setup was very simple: </p>
<p>running 3 processes, each on a different processor. Each process wrote to the log file in a loop, for some n iterations.  </p>
<p>I never had a problem.  If can you point me to scenarios where multiple processes actually do cause problems?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinay Sajip</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-1075</link>
		<dc:creator>Vinay Sajip</dc:creator>
		<pubDate>Sat, 15 Aug 2009 18:19:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-1075</guid>
		<description>Although a socket server for logging is not part of the library, one is documented in the Python documentation here:

http://docs.python.org/library/logging.html#sending-and-receiving-logging-events-across-a-network</description>
		<content:encoded><![CDATA[<p>Although a socket server for logging is not part of the library, one is documented in the Python documentation here:</p>
<p><a href="http://docs.python.org/library/logging.html#sending-and-receiving-logging-events-across-a-network" rel="nofollow">http://docs.python.org/library/logging.html#sending-and-receiving-logging-events-across-a-network</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marius Gedminas</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-1073</link>
		<dc:creator>Marius Gedminas</dc:creator>
		<pubDate>Fri, 14 Aug 2009 14:48:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-1073</guid>
		<description>I&#039;d appreciate it if you expanded a bit on what happens if you try to log to the same file from multiple Python processes.  Assuming you&#039;re running on a Unix-like OS with the files opened in append mode, log messages smaller than 4K and written in a single syscall, with flushing afterwards, I&#039;d expect things to work just fine.

Also, why sys.argv[1] and not sys.argv[0]?</description>
		<content:encoded><![CDATA[<p>I&#8217;d appreciate it if you expanded a bit on what happens if you try to log to the same file from multiple Python processes.  Assuming you&#8217;re running on a Unix-like OS with the files opened in append mode, log messages smaller than 4K and written in a single syscall, with flushing afterwards, I&#8217;d expect things to work just fine.</p>
<p>Also, why sys.argv[1] and not sys.argv[0]?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John P. Speno</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-1070</link>
		<dc:creator>John P. Speno</dc:creator>
		<pubDate>Fri, 14 Aug 2009 01:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-1070</guid>
		<description>Did you just reinvent syslog? O_o

Python&#039;s logging module supports syslog so consider using that if your system supports it. :-)</description>
		<content:encoded><![CDATA[<p>Did you just reinvent syslog? O_o</p>
<p>Python&#8217;s logging module supports syslog so consider using that if your system supports it. <img src='http://www.huyng.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Corfman</title>
		<link>http://www.huyng.com/archives/python-logging-from-multiple-processes/418/comment-page-1/#comment-1069</link>
		<dc:creator>Brandon Corfman</dc:creator>
		<pubDate>Thu, 13 Aug 2009 20:12:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.huyng.com/?p=418#comment-1069</guid>
		<description>Much appreciated. I have a multiprocessing project that needs this.</description>
		<content:encoded><![CDATA[<p>Much appreciated. I have a multiprocessing project that needs this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
