Vinay Sajip added the comment:

I don't believe this is logging-related - it relates to how you can rename open 
files on POSIX. Both loggers use the same file, until rollover - thereafter, 
they use different files, resulting in the behaviour you saw. To illustrate, 
run the following script on your system, which has no logging code:

# rotest.py
import os

FN = 'dummy-%s.log' % os.getpid()

print('Using %s' % FN)

fa = open(FN, 'a')
fb = open(FN, 'a')

aline = 'a' * 40 + '\n'
bline = 'b' * 40 + '\n'

for i in range(5):
    if i == 2:
        # simulate rollover of a
        fa.write('Rolling over - a\n'); fa.flush()
        fa.close()
        os.rename(FN, FN + '.1')
        fa = open(FN, 'a')
        fa.write('Rolled over - a\n'); fa.flush()
    if i == 3:
        # simulate rollover of b
        fb.write('Rolling over - b\n'); fa.flush()
        fb.close()
        os.rename(FN + '.1', FN + '.2')
        os.rename(FN, FN + '.1')
        fb = open(FN, 'a')
        fb.write('Rolled over - b\n'); fa.flush()
    fa.write(aline); fa.flush()
    fb.write(bline); fb.flush()

When run, I get the following results:

$ python rotest.py
Using dummy-2320.log
$ cat dummy-2320.log
Rolled over - b
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
$ cat dummy-2320.log.1
Rolled over - a
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
$ cat dummy-2320.log.2
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Rolling over - a
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Rolling over - b

As in your case, the oldest file contains both 'a' and 'b' lines, but after 
rollover, 'a' and 'b' lines are segregated.

Note that the script (and your approach) won't work on Windows, because there 
you can't rename open files (one handler has the file open even when the other 
has closed it).

Based on the above, I'm marking this issue as invalid. For obvious reasons, the 
approach you are using here is not recommended.

----------
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17407>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to