[Python-Dev] logging and rotation

Guido van Rossum guido at python.org
Sun Nov 25 18:33:58 CET 2012


On Sun, Nov 25, 2012 at 9:02 AM, Oleg Broytman <phd at phdru.name> wrote:
> On Sun, Nov 25, 2012 at 01:14:11PM +0100, Matthias Bernt <MatatTHC at gmx.de> wrote:
>> I'm using the logging module and write my log messages via the FileHandler.
>> I just realized that using an external log rotation mechanism does not
>> work. That is, new messages are not added to the file after
>> rotation.
>
>    An external log rotation mechanism ought to send a signal to the
> application and the application ought to close and reopen logs. That is,
> this is an application-level problem, not logging module-level.

I'm not so sure. Logging ought to "just work" without the application
having to do much about it the details. Log rotation is definitely a
useful feature; I've run into this very issue before and never found a
satisfactory solution. Surely it should be possible for the file
handler to occasionally stat() its output file by name and compare
that to fstat() for the file descriptor and if they differ, reopen?

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list