You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 05:06:17