Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28093
| From | Dieter Maurer <dieter@handshake.de> |
|---|---|
| Subject | Re: Can I get logging.FileHandler to close the file on each emit? |
| Date | 2012-08-30 09:24 +0200 |
| References | <3570ffff-749a-44c4-ab9e-10c37d9526e8@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3958.1346311469.4697.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Find similar | Unroll 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