login community faq

I have some debugging statements that I need to print out from my Django out, but I cannot find which file to look for them. They do not appear in the access logs or the error logs. Where can I find the file which they appear?

asked May 02 '12 at 22:16

kelp's gravatar image

kelp
12


Instead of using print statements you can use python's logging module. http://docs.python.org/howto/logging.html

answered May 04 '12 at 23:29

markusbarth's gravatar image

markusbarth
112

Print goes to sys.stdout, which is thrown away by mod_wsgi. You have to print to sys.stderr,

1
2
import sys
print >> sys.stderr, "string or object goes here"

This will send the output to the error log defined in httpd.conf. There are solutions that send sys.stdout to sys.stderr but they have unexpected side effects, the safest way is the above method.

answered May 02 '12 at 22:25

johns's gravatar image

johns ♦♦
345427

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×652
×236

Asked: May 02 '12 at 22:16

Seen: 842 times

Last updated: May 04 '12 at 23:29

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited