On 2014-08-16, Terry Reedy <tjre...@udel.edu> wrote:
> On 8/15/2014 11:04 PM, Russell E. Owen wrote:
>> We are using the syslog module for logging, and would like to redirect
>> stderr to our log. Is there a practical way to do it?
>
> You can replace sys.stderr with any object with a .write(s) method.

Just a remender: that that will only affect Python code running in the
current VM.  It doesn't actually change the Unix "stderr" file
descriptor (file number 2) that _might_ still be used by some external
libraries to print error messages, and it won't affect any child
processes (even Python apps).  You can deal with those cases by
replacing the standard error file descriptor with a log handler, but
it's a bit fiddly -- so I won't bother you with the details unless it
turns out you really need to do that.

-- 
Grant Edwards               grant.b.edwards        Yow! I can't decide which
                                  at               WRONG TURN to make first!!
                              gmail.com            I wonder if BOB GUCCIONE
                                                   has these problems!
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to