mod_wsgi未将Python异常回溯输出至httpd错误日志问题咨询
问题:mod_wsgi未输出Python异常回溯到错误日志
平台信息
httpd-2.4.62-1.el9_5.2.x86_64 python3-mod_wsgi-4.7.1-11.el9.x86_64 python3-3.9.21-1.el9_5.x86_64
httpd配置
WSGIDaemonProcess server.example.com \ processes=2 \ threads=5 \ display-name=%{GROUP} \ shutdown-timeout=100 \ python-path=/custom/python3 WSGIProcessGroup server.exmaple.com WSGIScriptAlias /test /var/www/cgi-bin/test.wsgi
/var/www/cgi-bin/test.wsgi 内容
import os,sys,logging print(sys.path) print('first') import foobar print("second") def application(environ, start_response): status = '200 OK' output = b'Hello World!\n' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
httpd错误日志输出
[wsgi:error] [pid 8260:tid 8405] ['/custom/python3'/usr/lib64/python39.zip', '/usr/lib64/python3.9', '/usr/lib64/python3.9/lib-dynload', '/usr/lib64/python3.9/site-packages', '/usr/lib/python3.9/site-packages'] [wsgi:error] [pid 8260:tid 8405] first
由于foobar模块不存在,脚本导入失败,因此从未打印“second”行。但异常回溯未输出至错误日志,核心问题并非导入本身,而是mod_wsgi完全没有将Python异常回溯写入错误日志。
内容的提问来源于stack exchange,提问作者Juha Tuomala
相关产品推荐
相关产品推荐

