gunicorn icon indicating copy to clipboard operation
gunicorn copied to clipboard

no access log when gunicorn work class as tornado

Open nnsay opened this issue 9 years ago • 5 comments

I has a gunicorn config as below:

bind = '127.0.0.1:3000'
workers = 2
worker_class = 'tornado'
proc_name = 'dome'
loglevel = 'debug'
pidfile = './gunicorn.pid'
accesslog = './log/access.log'
errorlog = './log/error.log'
raw_env = 'env=dev'

I do not find any access log when debugging. But I change worker_class as gevent, the access log is work! Why no access log when the gunicorn work class been set tornado ?

nnsay avatar Sep 28 '16 10:09 nnsay

maybe tornado is overriding the log config? I will check

benoitc avatar Oct 13 '16 11:10 benoitc

yeah, i have the same issue. basically, i cannot overwrite the default tornado.access logger in gunicorn_logconfig.ini

yunstanford avatar Jan 29 '17 23:01 yunstanford

I couldn't get tornado worker work with gunicorn master and tornado 4.4.2 by the way:

ERROR:tornado.application:Uncaught exception
Traceback (most recent call last):
  File "/home/berker/projects/gunicorn/venv34/lib/python3.4/site-packages/tornado/http1connection.py", line 238, in _read_message
    delegate.finish()
  File "/home/berker/projects/gunicorn/venv34/lib/python3.4/site-packages/tornado/httpserver.py", line 287, in finish
    self.server.request_callback(self.request)
  File "/home/berker/projects/gunicorn/venv34/lib/python3.4/site-packages/tornado/wsgi.py", line 304, in __call__
    request.connection.write_headers(start_line, header_obj, chunk=body)
  File "/home/berker/projects/gunicorn/venv34/lib/python3.4/site-packages/tornado/http1connection.py", line 398, in write_headers
    data += self._format_chunk(chunk)
  File "/home/berker/projects/gunicorn/venv34/lib/python3.4/site-packages/tornado/http1connection.py", line 410, in _format_chunk
    "Tried to write more data than Content-Length")
tornado.httputil.HTTPOutputError: Tried to write more data than Content-Length

berkerpeksag avatar Jan 30 '17 01:01 berkerpeksag

Is there any ETA for fix of this issue? or any workaround for the same.

ankitgarg2212gmailcom avatar May 26 '23 10:05 ankitgarg2212gmailcom

I imagine this would involve the following changes:

  • [ ] tell tornado to not setup conflicting logging, e.g. tornado.options.logging = "none"
  • [ ] patch tornado.wsgi.WSGIContainer to call our handler
  • [ ] patch tornado.web.Application to call our handler
  • [ ] patch environ (because we add non-rfc3875 keys such as RAW_URI and glogging will assert they are there)
  • [ ] forward size, request and response headers to our logging <= tricky without overriding internals / restricting supported versions

For reference, this is what I did to mock up access logs for the tornado worker for my testing purposes: https://github.com/benoitc/gunicorn/pull/3201/files#diff-233ae0d57e7947065c3b18f680f31643c2b97dfefa2665ce2d3afcceaab773e7

pajod avatar May 15 '24 01:05 pajod