You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@benoitc I am not sure this commit addresses this issue. Let us say I run, gunicorn myapp:app with no additional arguments. Is the expectation that gunicorn should log access records to standard output? If so, gunicorn doesn't do that.
In https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L302 without any command line arguments self.cfg.accesslog is None and the function returns early. As far as I can tell, there seems to be no way to log to stdout without specifing --log-config or --log-syslog. Is this correct?
@benoitc Yes. The discussion above seems to indicate that access logs will go to stdout and error logs to stderr. However, it looks like access logging is disabled by default.
BTW, with Python 2.7 I used to be able to do --access-log /dev/stdout --error-log /dev/stderr and that would work. With Python 3, passing /dev/stdout as an argument fails in
👍 @suriya I think I'm looking for the same behavior you are -- I'd like to run --capture-log and enable --access-logfile=<something>, but I'd prefer my access log lines go to stdout not stderr.
EDIT: To clarify, this appears to just be a problem with Python3. Using python3.5.1, passing --access-logfile=/dev/stdout to gunicorn fails to start the server.
@huoxyhttps://github.com/huoxy More than what the default is, I think
the issue is more that there is no simple way to write access logs to
standard output.
also it is probably a doc issue. but access log must be printed to stdout
when - is used. otherwise it is a bug. Let me know...
On Wed, 27 Jul 2016 at 09:03, Benoit Chesneau bchesneau@gmail.com wrote:
@huoxy ˋ--access-logfile=-` should do the trick. let me k'ow if not.
@huoxyhttps://github.com/huoxy More than what the default is, I think
the issue is more that there is no simple way to write access logs to
standard output.
@benoitc As mentioned in #1293, gunicorn --access-log - logs accesses to standard error. I tried with gunicorn --access-log=- and the log still goes to standard error.
default logger is console which outputs to stdout, so I guess if you need everything to stdout like me, for everything to get to the gunicorn logging driver, you can just leave those options blank.
I just moved to gunicorn 19.7.0 released last week. Unfortunately, I still can't get the access log written to anything other than stderr.
I've tried running gunicorn with no options and also with all permutations of including/not including "--access-logfile=- --error-logfile=- --log-level=DEBUG".
Am I missing something basic about gunicorn's logging? Is something from my environment or from Django possibly bleeding over and causing this problem?
I can confirm that the access log output goes to stdout.
Reacted by Jake Brinkmann, Kevin McCarthy, Manjeet Kumar, Ryan Hefner, Ravi Kotecha, Gunther Cox, Samuel Carlsson, Samuel Huang, sykp241095, Hyunjun Kim and 14 more
Activity
berkerpeksag commentedon Jan 19, 2016
The relevant line is here: https://github.com/benoitc/gunicorn/blame/master/gunicorn/glogging.py#L335
logging.StreamHandler()defaults tosys.stderr. Perhaps we could change accesslog to accept "stdout" and "stderr" as valid values and pass tologging.StreamHandler().berkerpeksag commentedon Jan 19, 2016
Another but less flexible solution:
The console handler already prints to
sys.stdout: https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L64 We could set the handler to "console" forgunicorn.accesslogas we already did forgunicorn.errorin https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L55benoitc commentedon Jan 19, 2016
I'm confused. Doesn't the StreamHandler already log on sys.stdout?
berkerpeksag commentedon Jan 19, 2016
No, the default value is
sys.stderr: https://github.com/python/cpython/blob/master/Lib/logging/__init__.py#L955benoitc commentedon Jan 22, 2016
OK I understand now. Originally we were printing logs to stdout. IMO the access log should default to STDOUT. Thoughts?
tilgovi commentedon Feb 11, 2016
@benoitc 👍
Access log on stdout
Error log on stderr
mannysz commentedon Apr 14, 2016
any updates on this request?
suriya commentedon May 11, 2016
@benoitc I am not sure this commit addresses this issue. Let us say I run,
gunicorn myapp:appwith no additional arguments. Is the expectation that gunicorn should log access records to standard output? If so, gunicorn doesn't do that.In https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py#L302 without any command line arguments
self.cfg.accesslogisNoneand the function returns early. As far as I can tell, there seems to be no way to log to stdout without specifing--log-configor--log-syslog. Is this correct?benoitc commentedon May 30, 2016
by default access log is disabled if this is what you mean?
suriya commentedon May 30, 2016
@benoitc Yes. The discussion above seems to indicate that access logs will go to stdout and error logs to stderr. However, it looks like access logging is disabled by default.
BTW, with Python 2.7 I used to be able to do
--access-log /dev/stdout --error-log /dev/stderrand that would work. With Python 3, passing/dev/stdoutas an argument fails ingunicorn/gunicorn/util.py
Line 498 in f722a6e
amilstead commentedon Jul 13, 2016
👍 @suriya I think I'm looking for the same behavior you are -- I'd like to run
--capture-logand enable--access-logfile=<something>, but I'd prefer my access log lines go to stdout not stderr.EDIT: To clarify, this appears to just be a problem with Python3. Using python3.5.1, passing
--access-logfile=/dev/stdoutto gunicorn fails to start the server.sykp241095 commentedon Jul 26, 2016
Yes, it looks like access logging is disabled by default.
suriya commentedon Jul 27, 2016
@huoxy More than what the default is, I think the issue is more that there is no simple way to write access logs to standard output.
benoitc commentedon Jul 27, 2016
@huoxy ˋ--access-logfile=-` should do the trick. let me k'ow if not.
On Wed, 27 Jul 2016 at 08:49, Suriya Subramanian notifications@github.com
wrote:
benoitc commentedon Jul 27, 2016
also it is probably a doc issue. but access log must be printed to stdout
when
-is used. otherwise it is a bug. Let me know...On Wed, 27 Jul 2016 at 09:03, Benoit Chesneau bchesneau@gmail.com wrote:
suriya commentedon Jul 27, 2016
@benoitc As mentioned in #1293,
gunicorn --access-log -logs accesses to standard error. I tried withgunicorn --access-log=-and the log still goes to standard error.make sure access logs are printed to stdout
BeOleg commentedon Jan 27, 2017
according to this:
https://github.com/gunicorn/gunicorn/blob/master/gunicorn/glogging.py#L58
default logger is
consolewhich outputs to stdout, so I guess if you need everything to stdout like me, for everything to get to the gunicorn logging driver, you can just leave those options blank.BeOleg commentedon Jan 27, 2017
Also, the solution I would suggest, is to create a symbolic link for the log files to
/dev/stdoutor/dev/stderrorif it does not work directly:Ghazgkull commentedon Mar 10, 2017
I just moved to gunicorn 19.7.0 released last week. Unfortunately, I still can't get the access log written to anything other than stderr.
I've tried running gunicorn with no options and also with all permutations of including/not including "--access-logfile=- --error-logfile=- --log-level=DEBUG".
Am I missing something basic about gunicorn's logging? Is something from my environment or from Django possibly bleeding over and causing this problem?
suriya commentedon Mar 10, 2017
With the application file myapp.py, I tried the following.
I can confirm that the access log output goes to
stdout.Ghazgkull commentedon Oct 2, 2017
I'm on Python 2.7.14. (Somehow missed the quick reply months ago.)
deka108 commentedon Nov 6, 2017
You can also use
accesslog = "-"in your gunicorn.config.pyprint error logs on stderr and access logs on stdout
make sure access logs are printed to stdout
print error logs on stderr and access logs on stdout