From df84d3d8fe6b2425f35d725a6c8259908672f35a Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 27 Jul 2016 09:29:56 +0200 Subject: [PATCH] make sure access logs are printed to stdout logging.StreamHandler deault to sys.stderr, so make sure access log are printed to stdout when choosing "-" by forcing the stream. Note: access logs were printed to stdout by default when using the config file. fix #1184 --- gunicorn/glogging.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 7dae434e0..e6f39970d 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -212,7 +212,7 @@ def setup(self, cfg): # set gunicorn.access handler if cfg.accesslog is not None: self._set_handler(self.access_log, cfg.accesslog, - fmt=logging.Formatter(self.access_fmt)) + fmt=logging.Formatter(self.access_fmt), stream=sys.stdout) # set syslog handler if cfg.syslog: @@ -373,7 +373,7 @@ def _get_gunicorn_handler(self, log): if getattr(h, "_gunicorn", False): return h - def _set_handler(self, log, output, fmt): + def _set_handler(self, log, output, fmt, stream=None): # remove previous gunicorn log handler h = self._get_gunicorn_handler(log) if h: @@ -381,7 +381,7 @@ def _set_handler(self, log, output, fmt): if output is not None: if output == "-": - h = logging.StreamHandler() + h = logging.StreamHandler(stream=stream) else: util.check_is_writeable(output) h = logging.FileHandler(output)