尽管使用谷歌搜索和阅读文档,我还是试图让 Python 日志记录工具正常工作,但没有成功。这是Dreamhost 共享服务器上Passenger 中的WSGI Python 应用程序。Paste 中间件正在努力提供有关 500 错误的信息。运行此代码时没有 python 错误。
我的消毒代码(passenger_wsgi.py):
#!/usr/bin/python
import os
import sys
import logging
cwd = os.getcwd()
sys.path.insert(0,cwd)
sys.path.append(cwd)
from paste.exceptions.errormiddleware import ErrorMiddleware
# configure the logging
logfilename = os.path.join('<path>/passenger_wsgi.log')
logging.basicConfig(filename=logfilename, level=logging.DEBUG, filemode='a+', format='%(asctime)s %(levelname)s %(message)s')
logging.info("Running %s", sys.executable)
log = file('<path>/passenger_wsgi_2.log', 'a')
print >>log, "Running %s" % (sys.executable)
log.flush()
application = ''
def application(environ, start_response):
results = ''
logging.info("Application called:")
logging.info("environ: %s", str(environ))
print >>log, "Application called:"
log.flush()
status = '200 OK'
results …Run Code Online (Sandbox Code Playgroud)