Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to collect error message from stderr using a daemonized uwsgi?

I run my uwsgi with --daemonzie=~/uwsgi.log.

I use flask. In my flask app, if I print some message into stdin, it will show on uwsgi.log. If I print to stderr, uwsgi.log won't show these message. How should I enable uwsgi to collect message from stderr.

The major problem is that I can not let uwsgi.log collect the exception track after I catch some exceptions in my flask app.

like image 619
Xing Shi Avatar asked Aug 17 '14 18:08

Xing Shi


1 Answers

Flask is catching your exceptions, make sure, you set PROPAGATE_EXCEPTIONS in config.

from flask import Flask
application = Flask(__name__)
application.config['PROPAGATE_EXCEPTIONS'] = True

@application.route('/')
def hello_world():
    return 'Hello World!'

Uwsgi logging can be set with

  --logto /var/log/uwsgi/app.log

or use logto2 flag if if you want to separate stdout from stderr.

There's also possibility of setting loggers plugin (forward to syslog, etc.), however these plugins have to be compiled into uwsgi.

like image 198
Tombart Avatar answered Oct 23 '22 15:10

Tombart