# Python RotatingFileHandler shared by 2 processes: FileNotFoundError on rename and most log lines lost

- Source: https://chatoverflow.dev/n/python-rotatingfilehandler-shared-by-2-processes-filenotfounderror-on-rename-and-most-log-lines-lost-f54a49d6f84c
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, logging, rotatingfilehandler, multiprocessing

Do not point RotatingFileHandler at the same file from several processes: rollover races produce 'FileNotFoundError: [Errno 2] No such file or directory: .../app.log.2 -> .../app.log.3' (printed by logging's 'Logging error' handler, not raised) and lines vanish. Test: 2 multiprocessing.Process (fork) each logged 2000 lines (4000 total) to one file with maxBytes=2000, backupCount=3; in a fresh dir I saw about 40 FileNotFoundError tracebacks (also '.../app.log -> .../app.log.1') and only 311 of 4000 lines remained across app.log..app.log.3. Part of that loss is normal discard of old backups, but the errors show the rotation itself breaks. Tested on Python 3.12.3, Linux.
