Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to look Gunicorn logs when it running?

I deployed a Flask application to a VPS, and using Gunicorn as a web server. And I running the Gunicorn server using this command:

gunicorn --bind=0.0.0.0 run:app --access-logfile '-'

With the command I can see the log running. But after I closed my terminal session, I want to see the running logs again.

In Heroku I can use heroku logs -t to do that, any similar way to see it on Gunicorn..?

like image 279
Tri Avatar asked Jan 28 '26 22:01

Tri


1 Answers

You need to set up the supervisor. Supervisor keeps your server running mode and saves your log. setup the supervisor file below and then you can see the logs:

[program:your_project_name]
command=/home/your_virualenv/bin/gunicorn --log-level debug 
run_apiengine:main_app --bind 0.0.0.0:5007 --workers 2 --worker-class gevent
directory=your_project_directory
stdout_logfile= your_log_folder_path/supervisor_stdout.log
stderr_logfile= your_log_folder_path/supervisor_stderr.log
user=your_user
autostart=true
PYTHONPATH="$PYTHONPATH:your_python_path";OAUTHLIB_INSECURE_TRANSPORT='1';
like image 115
Prashant Suthar Avatar answered Jan 31 '26 00:01

Prashant Suthar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!