[Django]-Where to see stdout if I use mod_wsgi to serve application?

2👍

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")
👤Alex L

1👍

wsgilog is simple, and can redirect standard out to a log file automatically for you. Breeze to set up, and I haven’t had any real problems with it.

0👍

No WSGI application component which claims to be portable should write to standard output. That is, an application should not use the Python print statement without directing output to some alternate stream. An application should also not write directly to sys.stdout. (ModWSGI Wiki)

So don’t… Instead, I recommend using a log aggregation tool like sentry. It is useful while developing and a must-have in production.

Leave a comment