I inherited a flask server running behind a gun and a supervisor. In the log file I want to see:
- All incoming requests
- All outgoing replies
I have a lot of gunsmith workers. My gunicorn.conf.py looks like this:
import multiprocessing bind = "0.0.0.0:8000" workers = multiprocessing.cpu_count() * 2 + 1 worker_class = 'gevent' max_requests = 1000 timeout = 30 keep_alive = 2 preload = True
and gunicorn.conf for supervisor as follows:
[program:gunicorn] command=/opt/anaconda/bin/gunicorn manage:app -c /etc/config/gunicorn.conf.py directory=/root/ourthing/web environment=PYTHONPATH=/root/ourthing/web user=root autorestart=true stdout_logfile=/opt/logs/gunicorn_stdout.log stderr_logfile=/opt/logs/gunicorn_stderr.log loglevel=info priority=400
With loglevel=info I expected to see requests and answers in gunicorn_stdout.log and gunicorn_stderr.log , but not the cubes.
I have implemented this for logging and it works, but in order to manually send each request and response using logger.info , it seems insane.
Is there somewhere here where this just happens automatically?
If so, where is it?
In addition, I assume that all workers write to the same journal ....
EDIT: Here is what I added to gunicorn.conf.py through the accepted answer:
accesslog = '/root/logs/accesslog.log' loglevel = 'debug' access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
python flask gunicorn supervisor
bahmait
source share