Redirect stdout and stderr to file in Django with wsgi -
i'm trying make django work wsgi in shared hosting, cannot access server logs,
i'm trying redirect output file in django.wsgi script, this:
saveout = sys.stdout log_out = open('out.log', 'w') sys.stdout = log_out
but error have (in error log can access)
[thu oct 07 19:18:08 2010] [error] [client <ip>] file "/home/myuser/public_html/django.wsgi", line 9, in <module> [thu oct 07 19:18:08 2010] [error] [client <ip>] mod_wsgi (pid=30677): exception occurred processing wsgi script '/home/myuser/public_html/django.wsgi'.
and error can get
line 9 1 tries open file. i've tried creating file, giving writing access everyone, without file created.. , nothing. in app, 500 server error.
is there proper way output without access apache logs?
edited:
using absolute paths, can open files , write them, empty files unless close files in end, necessary? leave files open?..
regarding initial problem, though used exception handling, write "finish ok" file in end of script, close file, still error:
[thu oct 07 13:33:07 2010] [error] [client <ip>] mod_wsgi (pid=32541): exception occurred processing wsgi script '/home/myuser/public_html/django.wsgi'.
if intentionally raise error, logged in file, "ok" think script worked fine result still message error... no clues
you can't use relative pathnames out.log
in wsgi application. wsgi doesn't specify working directory pointing , mod_wsgi doesn't set unless asked in daemon mode.
use absolute pathname based on application's root. can use os.path.dirname(__file__)
directory containing current script/module if needed.
Comments
Post a Comment