I don't believe you need to be doing all kinds of acrobatics with apache and your python process. On Linux and Unix machines, you can tell the stock syslog daemon that messages sent to a certain syslog facility are to be sent to a named pipe. So, if you tell syslog that, say, the local6 facility should go to a named pipe, then point apache at that to do its logging,  then your script becomes as simple as reading from the named pipe. <div>

<br></div><div>I did something years ago similar to this to get syslog messages sent to my jabber client. It's perl (it predates my conversion to python), but doing the same in python would be way easier :) </div><div>

<br></div><div>The code is here:</div><div><br></div><div><a href="http://linuxlaboratory.org/snippets/2/">http://linuxlaboratory.org/snippets/2/</a></div><div><br></div><div>And an old article from Linux.com which explains the syslog bits is here: </div>

<div><br></div><div><a href="http://www.linux.com/archive/feature/36631">http://www.linux.com/archive/feature/36631</a></div><div><br></div><div>I occasionally still hear from people that all of it still works. </div><div>

hth. </div><div>brian<br><br><div class="gmail_quote">On Sun, Sep 26, 2010 at 5:20 AM, Stefan Schwarzer <span dir="ltr"><<a href="mailto:sschwarzer@sschwarzer.net">sschwarzer@sschwarzer.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi Daniel,<br>
<div class="im"><br>
On 2010-09-23 07:30, vineet daniel wrote:<br>
> On Sep 22, 2:20 pm, <a href="mailto:de...@web.de">de...@web.de</a> (Diez B. Roggisch) wrote:<br>
>> vineet daniel <<a href="mailto:vineetdan...@gmail.com">vineetdan...@gmail.com</a>> writes:<br>
>>> On Sep 21, 9:47 pm, <a href="mailto:de...@web.de">de...@web.de</a> (Diez B. Roggisch) wrote:<br>
>>>> vineet daniel <<a href="mailto:vineetdan...@gmail.com">vineetdan...@gmail.com</a>> writes:<br>
</div><div class="im">>>>>> code that I am using is as follows :<br>
>><br>
>>>>> #! /usr/bin/env python<br>
>>>>> import sys,os<br>
>>>>> pid = os.fork()<br>
>>>>> os.chdir("/var/www/html/")<br>
>>>>> os.setsid()<br>
>>>>> os.umask(0)<br>
>>>>> #this line will read apache log in real time as redirected from the<br>
>>>>> CustomLog directive of Apache.<br>
>>>>> log = sys.stdin.readlines()<br>
>>>>> f = open('/var/www/logmongo.txt','a') # append log to this text file<br>
>>>>> f.write(log)<br>
<br>
</div>I guess you'll need some loop to process the input from<br>
Apache.<br>
<div class="im"><br>
> There is a directive in Apache - CustomLog which can redirect logs to<br>
> a script or another file by using Pipe. I googled about it and came to<br>
> know that this works flawlessly with Perl as Apache treats Perl<br>
> scripts as daemon, for Python to take input from Apache, it needs to<br>
> work as daemon. Apache will then push its logs lines to this daemon as<br>
> input. Perl takes this input as <stdin> but python's stdin is not<br>
> working as expected it just takes the file name as given in CustomLog<br>
> directive using Pipe i.e if I use CustomLog '|/var/wwww/script.py'<br>
<br>
</div>Are the _four_ ws intentional?<br>
<div class="im"><br>
> combined, what script reads is just the file name, how and why I am<br>
> not able to figure it out. And thats the reason I am here. I hope<br>
> you've got what I am trying to do.<br>
<br>
</div>Do you have a line for the interpreter at the top of your<br>
script, like<br>
<br>
#!/usr/bin/python<br>
<br>
Is the script executable (e. g. chmod +x script.py)?<br>
<font color="#888888"><br>
Stefan<br>
</font><div><div></div><div class="h5"><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Brian K. Jones<br>My Blog          <a href="http://www.protocolostomy.com">http://www.protocolostomy.com</a><br>Follow me      <a href="http://twitter.com/bkjones">http://twitter.com/bkjones</a><br>


</div>