mod_wsgi-express 设置日志级别
mod_wsgi-express set log level
如何在以
启动的wsgi应用程序中设置日志级别
mod_wsgi-express ./mywsgi.py
?这是最简单的设置。 Logging in python + mod_wsgi app talks about config files, as does the Quick Configuration Guide。 mod_wsgi-express
命令只需要pythonwsgi文件即可运行。
使用--log-level
标志,如the release notes
中所述
mod_wsgi-express --log-level info ./mywsgi.py
未显示 logging.info
消息。 --debug-mode
标志也没有 mentioned by @GrahamDumpleton.
已解决(见下文),但仍然是:最小示例
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
def application(environ, start_response):
status = '200 OK'
logging.warning('warning log message')
logging.info('info log message')
output = "hello world"
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
您还(参见上面的示例)需要在 wsgi 程序中启用 INFO
(f.ex.) 级别的日志记录。例如通过行
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
如果您随后从 --log-level info
开始,您会在 error_log
中看到 logging.info
输出。
如何在以
启动的wsgi应用程序中设置日志级别mod_wsgi-express ./mywsgi.py
?这是最简单的设置。 Logging in python + mod_wsgi app talks about config files, as does the Quick Configuration Guide。 mod_wsgi-express
命令只需要pythonwsgi文件即可运行。
使用--log-level
标志,如the release notes
mod_wsgi-express --log-level info ./mywsgi.py
未显示 logging.info
消息。 --debug-mode
标志也没有 mentioned by @GrahamDumpleton.
已解决(见下文),但仍然是:最小示例
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
def application(environ, start_response):
status = '200 OK'
logging.warning('warning log message')
logging.info('info log message')
output = "hello world"
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
您还(参见上面的示例)需要在 wsgi 程序中启用 INFO
(f.ex.) 级别的日志记录。例如通过行
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
如果您随后从 --log-level info
开始,您会在 error_log
中看到 logging.info
输出。