[Tutor] python logging module: two handlers writing to the samefile - okay?
Tiger12506
keridee at jayco.net
Sat Dec 15 19:04:52 CET 2007
----- Original Message -----
From: "Hans Fangohr" <h.fangohr at soton.ac.uk>
To: <tutor at python.org>
Sent: Saturday, December 15, 2007 1:43 AM
Subject: [Tutor] python logging module: two handlers writing to the
samefile - okay?
> I have an example program (test.py) and the logging configuration file
> (log.conf) attached below (they are also available at
> http://www.soton.ac.uk/~fangohr/geheim/two_handlers_one_file)
> (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 have seen this not working when both files are opened with mode
> 'w'.)
I think this makes sense. 'w' mode automatically blanks out the file before
writing. So each time that the file is opened, whatever was in it before is
gone. Also, there may be some sort of difference due to the '+' which means
to open the file in update mode. What that means still makes little sense to
me. I *think* it has something to do with whether the file can be read and
written without different file handles. But that doesn't seem to matter in
python. Does someone know about this? Maybe a new thread...
Thanks,
JS
More information about the Tutor
mailing list