Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing access log to standard output #1293

Closed
suriya opened this issue Jun 6, 2016 · 7 comments
Closed

Printing access log to standard output #1293

suriya opened this issue Jun 6, 2016 · 7 comments

Comments

@suriya
Copy link
Contributor

suriya commented Jun 6, 2016

I apologize if what I am saying is wrong.

As far as I can tell, I don't see any easy way to print access logs to stdout. I see issue #1184. However, the fix does not seem to work. Invoking gunicorn without any arguments does no access logging. Invoking gunicorn --access-log - sends log messages to standard error (with gunicorn 19.6.0).

I someone could let me know how to get error messages logged to standard error and access logs to standard output, I'd appreciate it.

@tilgovi
Copy link
Collaborator

tilgovi commented Jun 10, 2016

It does seem as thought --access-log - should probably mean stdout.

@benoitc
Copy link
Owner

benoitc commented Jun 10, 2016

It should be gunicorn --access-log=-. In theory it should be redireted to stdout:

https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L61-L77

If not, I will check what's missing.

@berkerpeksag
Copy link
Collaborator

Yes, the gunicorn.access logger should print to sys.stdout: https://github.com/benoitc/gunicorn/blame/master/gunicorn/glogging.py#L72 I think documentation is outdated: http://docs.gunicorn.org/en/stable/settings.html#accesslog

@tilgovi
Copy link
Collaborator

tilgovi commented Jun 11, 2016

The documentation is not out of date, but the behavior seems a little broken. From the CONFIG_DEFAULTS that you link to, @berkerpeksag, it seems as though the intention is for access log to go to stdout. However, that is the default configuration that the --log-config setting merges into.

Without --log-config, the default for accesslog is None (from config.py) and so no handler is set up for the access log: https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L213

With --access-log -, we might expect to get stdout. The documentation correctly states that it means stderr, because that's the default for a StreamHandler as created by Logger._set_handler: https://docs.python.org/2/library/logging.handlers.html#logging.StreamHandler

@tilgovi
Copy link
Collaborator

tilgovi commented Jun 11, 2016

I propose we change the handling of - for the access log setting to mean stdout.

@benoitc
Copy link
Owner

benoitc commented Jul 27, 2016

fixed in df84d3d . It was already defaulting to stdout by using the config file btw.

@benoitc benoitc closed this as completed Jul 27, 2016
@suriya
Copy link
Contributor Author

suriya commented Jul 27, 2016

@benoitc Works as expected. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants