Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to see stdout if I use mod_wsgi to serve application?

Sometimes I need to check the output of a python web apllication.

If I execute the application directly, I can see it from terminal screen.

But I have no idea how to check that for mod_wsgi. Will it appear in a seperate log of apache? Or do I need to add some codes for logging?

like image 587
Hanfei Sun Avatar asked Nov 01 '25 07:11

Hanfei Sun


1 Answers

Instead of print "message", you could use sys.stderr.write("message")

For logging to stderr with a StreamHandler:

import logging
handler = logging.StreamHandler(stream=sys.stderr)
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
log.addHandler(handler)

log.info("Message")
like image 102
Alex L Avatar answered Nov 03 '25 19:11

Alex L



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!