Skip to content

Commit

Permalink
make sure access logs are printed to stdout
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benoitc committed Jul 27, 2016
1 parent 13d1937 commit df84d3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gunicorn/glogging.py
Expand Up @@ -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:
Expand Down Expand Up @@ -373,15 +373,15 @@ 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:
log.handlers.remove(h)

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)
Expand Down

0 comments on commit df84d3d

Please sign in to comment.