[Tutor] python logging module: two handlers writing to the same file - okay?
Kent Johnson
kent37 at tds.net
Sat Dec 15 14:30:27 CET 2007
Hans Fangohr wrote:
> (i) is this (as in the log.conf file) the right use of the logging
> module to achieve what I need?
I think you understand the module correctly.
> (ii) in particular, it appears we have two filehandlers that write to
> the same file (in mode 'a+'). While this seems to work fine in the
> examples I have tested, I'd like some independent advice on whether
> this is 'legal' (or whether it works by chance).
I don't know the answer, but it has nothing to do with the logging
module. The question is, can the same file reliably be opened twice for
writing in the same module.
Another option: If you configure logging in code, you could create two
StreamHandlers that log to the same file - open the file yourself and
pass it to both handlers. If you do this you will have to close the file
yourself somehow.
Kent
More information about the Tutor
mailing list