Question
Asked By – Justin Grant
How can I send trace messages to the console (like print
) when I’m running my Django app under manage.py runserver
, but have those messages sent to a log file when I’m running the app under Apache?
I reviewed Django logging and although I was impressed with its flexibility and configurability for advanced uses, I’m still stumped with how to handle my simple use-case.
Now we will see solution for issue: Python/Django: log to console under runserver, log to file under Apache
Answer
Text printed to stderr will show up in httpd’s error log when running under mod_wsgi. You can either use print
directly, or use logging
instead.
print >>sys.stderr, 'Goodbye, cruel world!'
This question is answered By – Ignacio Vazquez-Abrams
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0