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


Groups > comp.lang.python > #28093

Re: Can I get logging.FileHandler to close the file on each emit?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'handler': 0.04; 'subject:file': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'closes': 0.16; 'linux)': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'windows': 0.19; 'module': 0.19; '(not': 0.20; 'not,': 0.21; '(on': 0.22; "python's": 0.23; 'tried': 0.25; 'header:User- Agent:1': 0.26; 'handling': 0.27; 'correct': 0.28; 'header:X -Complaints-To:1': 0.28; 'usable': 0.29; 'writes:': 0.29; 'this.': 0.29; 'maybe': 0.29; 'file': 0.32; 'running': 0.32; 'event.': 0.33; 'to:addr:python-list': 0.33; 'process,': 0.35; 'subject:?': 0.35; 'something': 0.35; 'next': 0.35; 'received:org': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.37; 'does': 0.37; 'subject:: ': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'close': 0.63; 'email addr:gmail.com': 0.63; 'received:217': 0.68; 'subject:get': 0.81; 'maybe,': 0.84; 'subject:skip:l 10': 0.84; 'windows)': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dieter Maurer <dieter@handshake.de>
Subject Re: Can I get logging.FileHandler to close the file on each emit?
Date Thu, 30 Aug 2012 09:24:09 +0200
References <3570ffff-749a-44c4-ab9e-10c37d9526e8@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e09039.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:eJw3w5aCyx5hv6CL6mCojZRai10=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3958.1346311469.4697.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346311470 news.xs4all.nl 6876 [2001:888:2000:d::a6]:50239
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28093

Show key headers only | View raw


rikardhulten@gmail.com writes:

> I use logging.FileHandler (on windows) and I would like to be able to delete the file while the process is running and have it create the file again on next log event.
>
> On windows (not tried linux) this is not possible because the file is locked by the process, can I get it to close the file after each log event?
>
> If not, would the correct thing to do be to write my own LogHandler with this behavior?

Zope is using Python's "logging" module and wants to play well
with log rotating (start a new logfile, do something with the old log file
(compress, rename, remove)).
It does this by registering a signal handler which closes its logfiles
when the corresponding signal is received.

Maybe, you can do something like this. Signal handling under
Windows is limited, but maybe you find a usable signal under Windows
(Zope is using "SIGUSR1").

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


Thread

Can I get logging.FileHandler to close the file on each emit? rikardhulten@gmail.com - 2012-08-29 03:18 -0700
  Re: Can I get logging.FileHandler to close the file on each emit? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-29 13:49 +0100
    Re: Can I get logging.FileHandler to close the file on each emit? rikardhulten@gmail.com - 2012-08-29 05:57 -0700
  Re: Can I get logging.FileHandler to close the file on each emit? Dieter Maurer <dieter@handshake.de> - 2012-08-30 09:24 +0200

csiph-web