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


Groups > comp.lang.python > #76478

Re: redirect stderr to syslog?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!not-for-mail
From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: redirect stderr to syslog?
Date Mon, 18 Aug 2014 13:52:37 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 21
Message-ID <lst0f5$eso$1@reader1.panix.com> (permalink)
References <rowen-500811.20043015082014@news.gmane.org> <mailman.13045.1408174032.18130.python-list@python.org>
NNTP-Posting-Host dsl.comtrol.com
X-Trace reader1.panix.com 1408369957 15256 64.122.56.22 (18 Aug 2014 13:52:37 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Mon, 18 Aug 2014 13:52:37 +0000 (UTC)
User-Agent slrn/1.0.1 (Linux)
X-Received-Bytes 1905
X-Received-Body-CRC 805017177
Xref csiph.com comp.lang.python:76478

Show key headers only | 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