Efficient way of looging in python

Skip Montanaro skip at pobox.com
Thu Apr 25 09:43:31 EDT 2013


> a) If multiple processes are trying to write to the same file, I need to prevent that.

Two things: Use some sort of file locking.  You can get the lockfile
module from PyPI. Include at least the process id as one of the
logging fields in your formatter.  I haven't don't enough with the
logging module to know it it supports some sort of "name" field, which
would make the different messages more easily distinguished, but if
so, that would be a better alternative to the process id.

Skip



More information about the Python-list mailing list