This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [logging] allow %p code to put PID into log filename
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: steveha, vinay.sajip
Priority: normal Keywords:

Created on 2018-05-14 20:58 by steveha, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg316576 - (view) Author: Steve R. Hastings (steveha) * Date: 2018-05-14 20:58
Python logging is not multi-process safe.  When a Python program has multiple processes, one way to log safely would be to put the process ID number into the filename of the log file, giving each process its own log file.

It would be convenient if a %p format code would be expanded to the process ID number when the logging system opens the log file.
msg316602 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2018-05-14 22:31
> Python logging is not multi-process safe.

Covered in

https://docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes

You can certainly arrange to have the pid in the filename without a change to the stdlib. I don't propose to implement this.
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77689
2018-05-15 07:49:31vinay.sajipsetstatus: open -> closed
resolution: rejected
stage: resolved
2018-05-14 22:31:24vinay.sajipsetmessages: + msg316602
2018-05-14 20:58:10stevehacreate