Machine-gun and supervisor bottle - register all requests and answers

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"' 
+7
python flask gunicorn supervisor
source share
1 answer

The loglevel configuration parameter only affects the error log, so changing its value will not help you log successful requests and responses.

Instead, try setting accesslog (to enable access logs) and access_log_format in the access_log_format configuration file.

+7
source share

All Articles