Leandro M Barbosa
Leandro M Barbosa

Reputation: 540

How do I log using gunicorn and multiprocessing?

How do I use python logging to log my application code (not access logs) in a multiprocessing gunicorn (and Flask) application?

Do I need centralized logging solution or I could somehow use a file? Is it safe to just point each process to the same file?

Upvotes: 6

Views: 1732

Answers (1)

DorElias
DorElias

Reputation: 2313

You can use multiprocessing logger:

https://docs.python.org/2/library/multiprocessing.html#logging

Or if you want you can write the logs to a different file in each process by concating the pid to the file name

Upvotes: 3

Related Questions