Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76478

Re: redirect stderr to syslog?

From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: redirect stderr to syslog?
Date 2014-08-18 13:52 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <lst0f5$eso$1@reader1.panix.com> (permalink)
References <rowen-500811.20043015082014@news.gmane.org> <mailman.13045.1408174032.18130.python-list@python.org>

Show all headers | View raw


On 2014-08-16, Terry Reedy <tjreedy@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!

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: redirect stderr to syslog? Terry Reedy <tjreedy@udel.edu> - 2014-08-16 03:26 -0400
  Re: redirect stderr to syslog? Grant Edwards <invalid@invalid.invalid> - 2014-08-18 13:52 +0000

csiph-web