People,<br><br>Can anyone help me with this issue?<br><br>log.startLogging(open(logname,&#39;w&#39;)<br>or <br>log.startLogging(open(logname,&#39;w&#39;), setStdout=True)<br><br>Both print the console output in the log. But nothing is displayed on console! So I get a empty console<br>
I would like to keep the console going also:<br><br>Precisely:<br>Console -&gt; gets the print calls                             Not Happening <br>Log       -&gt; gets the print calls + log.msg calls      Happening<br><br>
I understand that this might be a trivial issue, but I am not able to figure it out in the documentation available :(<br><br>Thanks for any help<br><br>Regards<br>Naman<br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 7:43 AM, naman jain <span dir="ltr">&lt;<a href="mailto:namanvit@gmail.com">namanvit@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>Using  log.startLogging(open(logname, &#39;w&#39;), setStdout=False)<br>very well solves the issue.. of stdout remaining untouched and log.msg() calls going to log<br>
<br>Can we do this ?:<br>Log file gets -&gt; both the log.msg() calls , the stdout +stderr<br>
console -&gt; gets stdout +stderr as usual<br><br>Regards<br><font color="#888888">Naman</font><div><div></div><div class="h5"><br><br><br><div class="gmail_quote">On Fri, Oct 30, 2009 at 9:25 PM, David Bolen <span dir="ltr">&lt;<a href="http://db3l.net" target="_blank">db3l.net</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>naman jain &lt;<a href="mailto:namanvit@gmail.com" target="_blank">namanvit@gmail.com</a>&gt; writes:<br>


<br>
&gt; I wanted to log in a file and keep the console also going with it.<br>
<br>
</div>I can read this as either:<br>
<br>
  * Keep file logs and stdout/console completely separate, or<br>
  * File gets explicit logs and copies of stdout, but stdout also goes to<br>
    console as well.<br>
<br>
The latter is something I&#39;d more commonly do, but the former is what<br>
you explain further below with your rules.<br>
<div><br>
&gt; I am using<br>
&gt; log.startLogging(open(logname, &#39;w&#39;))<br>
&gt;<br>
&gt; whatever documentation I could find about this API, it suggested me to pass<br>
&gt; setStdout=False(in order to keep stdout away from putting into log)<br>
&gt; somewhere in the startlogging function.<br>
&gt;<br>
&gt; Something like this I tried:<br>
&gt; log.startLogging(sys.stdout,setStdout=False)<br>
<br>
</div>Why did you switch to sys.stdout here?  While this will prevent<br>
sys.stdout and sys.stderr from being redirected, it will use<br>
sys.stdout for any log.msg() calls, so nothing would end up in your<br>
log file.<br>
<div><br>
&gt; Doesnt help in solving the problem of getting both things:<br>
&gt;<br>
&gt; Requirement:<br>
&gt; log.msg(&quot;messageforlog&quot;)    -&gt; goes to log<br>
&gt; print &quot;message for console&quot; -&gt; goes to console<br>
&gt;<br>
&gt; Could anyone give some ideas on this?<br>
<br>
</div>I think you had the right idea with setStdout, but changed more than<br>
just that when you tested it.  If you use a call like<br>
log.startLogging(open(logname, &#39;w&#39;), setStdout=False) I believe you&#39;ll<br>
get what you want.  Only calls to log.msg() will go to the file, and<br>
stdout/stderr will be left unchanged.<br>
<br>
-- David<br>
<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br>
</div></div></blockquote></div><br>