Opened 14 years ago

Closed 14 years ago

#14625 closed (wontfix)

Docs on logging should emphasize that file logging is not multiprocess save

Reported by: Piotr Czachur Owned by: nobody
Component: Documentation Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

python logging facility is not multiprocess save:

"Although logging is thread-safe, and logging to a single file from multiple threads in a single process is supported, logging to a single file from multiple processes is not supported [...]" (http://docs.python.org/library/logging.html#logging-to-a-single-file-from-multiple-processes)

"Not supported" means your logs from multiple process can mix in chunks due to buffering issues (I tested it for long messages ~5k - their chunks just got mixed)

Django popular deployment is mod_wsgi/multiprocess so it can be the issue.

Change History (2)

comment:1 by Piotr Czachur, 14 years ago

You may provide http://pypi.python.org/pypi/ConcurrentLogHandler as alternative for RotatingFileHandler

comment:2 by Gabriel Hurley, 14 years ago

Resolution: wontfix
Status: newclosed

At present, Django's docs give no recommendation to use FileHandler (or RotatingFileHandler) at all. The docs instead direct people to the Python logging docs, which do cover the issue you raised, though not as loudly or obviously as might be desired.

I agree that logging to a file is a common practice, and that using RotatingFileHandler is a common practice, but I really see this as a failure of the Python documentation that the issue is not more clearly noted.

As such, I would say this ticket should be directed at the Python docs rather than the Django docs until such time as Django has specific recommendations or examples regarding specific file-logging configurations.

If you feel that Django's documentation *should* have recommended logging configurations that's a whole different issue, and will probably require building consensus on the Django Developers mailing list.

Note: See TracTickets for help on using tickets.
Back to Top