David
David

Reputation: 605

Logging in gunicorn log file is not detailed

I'm setting log level to 'debug' which I recall is the most verbose, however I'm only getting lines like this, even when an exception is thrown:

[2018-04-18 22:08:21 +0000] [23394] [DEBUG] POST /json

My startup command is this:

gunicorn  --log-level debug --error-logfile gunicorn_error.log  -D -b 0.0.0.0:5000 forward_to_es:app

Thanks for any suggestions.

Upvotes: 6

Views: 28138

Answers (3)

tomo.hirano
tomo.hirano

Reputation: 71

--access-logfile option may be required like:

gunicorn --access-logfile /tmp/gunicorn.log --error-logfile /tmp/gunicorn.log --capture-output --log-level info

Upvotes: 0

Emmanuel Orozco
Emmanuel Orozco

Reputation: 389

Sorry for the delay, You need to add:

capture_output=True

in your gunicorn_config.py

Upvotes: 1

jalazbe
jalazbe

Reputation: 1995

I recommend that you create a gunicorn config file. for example:

# /path-to-your-project/gunicorn_conf.py
bind = '0.0.0.0:8811'
worker_class = 'sync'
loglevel = 'debug'
accesslog = '/var/log/gunicorn/access_log_yourapp'
acceslogformat ="%(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s"
errorlog =  '/var/log/gunicorn/error_log_yourapp'

In the documentation you may find all possible identifiers for your access log.

Then just do

/path-to-your-project/gunicorn -c gunicorn_conf.py forward_to_es:app

This way you may have one or more configurations or even create various logs depending on the configuration you are trying.

Upvotes: 5

Related Questions