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


Groups > comp.lang.python > #76398 > unrolled thread

Re: redirect stderr to syslog?

Started byTerry Reedy <tjreedy@udel.edu>
First post2014-08-16 03:26 -0400
Last post2014-08-18 13:52 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#76398 — Re: redirect stderr to syslog?

FromTerry Reedy <tjreedy@udel.edu>
Date2014-08-16 03:26 -0400
SubjectRe: redirect stderr to syslog?
Message-ID<mailman.13045.1408174032.18130.python-list@python.org>
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.


-- 
Terry Jan Reedy

[toc] | [next] | [standalone]


#76478

FromGrant Edwards <invalid@invalid.invalid>
Date2014-08-18 13:52 +0000
Message-ID<lst0f5$eso$1@reader1.panix.com>
In reply to#76398
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!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web