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>Naman<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">db3l.net</a>@<a href="http://gmail.com">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 class="im">naman jain &lt;<a href="mailto:namanvit@gmail.com">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 class="im"><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 class="im"><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">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>