-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Log messages from Flask's app.logger #379
Comments
Flask does not log messages in production mode by default because it does not make any assumptions about your environment (http://flask.pocoo.org/docs/errorhandling/). To get Flask's app.logger to log messages via gunicorn, you'll have to add a logging handler. For example, here's a logger to gunicorn's stderr:
This is not an issue with gunicorn and can be closed. |
closed per request. Thanks! |
Does gunicorn automatically pick up the log from STDERR? |
@benoitc |
The -R flag might be what you're looking for. http://gunicorn-docs.readthedocs.org/en/latest/settings.html#enable-stdio-inheritance |
-R did not do it for me. Below is my setup
Here is how I run it
I get the gunicorn logs in /mnt/log/test.log but none of my application logs. |
Okay. I may misunderstand how that works, unless it's a simple matter of But it's definitely much easier to control where your log messages go if
|
@spicavigo gunicorn won't redirect the stderr to the logfile automatically. The fix was to remove the hack like it was discussed in #591 . Did you try If you want to directly return error to the error file you can eventually print to environ['wsgi.errors'] or log it: ee08ac8 . |
Thanks @benoitc I am now logging to a file instead of stderr. Its just that the change happened in between my dev and so it totally tripped me. I was pip install gunicorn and suddenly the stderr redirect stopped working and I didn't realize it was because of version change and not due to bugs in my code :) |
@benoitc Is it still possible to log stderr to the logfile somehow? |
Send Flask log records to stderr, which gunicorn picks up. From benoitc/gunicorn#379
See integration of pallets/flask#2436 (Simplify logging), the workaround originally suggested in benoitc/gunicorn#379 is not needed anymore.
Messages from Flask's logger such as app.logger.info("This is a message") are not saved in the gunicorn log files.
The text was updated successfully, but these errors were encountered: