2

我正在尝试在我的 Openshift python 3.3 应用程序上使用 Cherrypy 设置日志记录。'appserver.log' 文件仅在实际服务器启动之前更新,然后不会将任何内容添加到日志文件中。我已阅读并遵循(据我所知)以下链接中的文档。仍然没有记录。

CherryPy 服务器错误日志

http://docs.cherrypy.org/dev/refman/_cplogging.html

我的python代码片段:

def run_cherrypy_server(app, ip, port=8080):
   from cherrypy import wsgiserver
   from cherrypy import config

# log.screen:           Set this to True to have both “error” and “access” messages printed to stdout.
# log.access_file:      Set this to an absolute filename where you want “access” messages written.
# log.error_file:       Set this to an absolute filename where you want “error” messages written.

appserver_error_log = os.path.join(os.environ['OPENSHIFT_HOMEDIR'], 'python', 'logs','appserver_error.log')
appserver_access_log = os.path.join(os.environ['OPENSHIFT_HOMEDIR'], 'python', 'logs','appserver_access.log')



config.update({
        'log.screen': True,
        'log.error_file': appserver_error_log,
        'log.access_file': appserver_access_log
       })

server = wsgiserver.CherryPyWSGIServer(
       (ip, port), app, server_name='www.cherrypy.example')
server.start()

'appserver_error.log' 和 'appserver_access.log' 文件实际上是在正确的 Openshift python 目录中创建的。但是,文件 appserver_error.log 和 appserver_access.log 中都没有日志记录信息。

一切运行良好,但没有日志记录。

任何想法我做错了什么?

4

1 回答 1

3

WSGI 服务器本身不做任何日志记录。CherryPy 引擎(控制进程启动和关闭)写入“错误”日志,只有 CherryPy 应用程序(使用 CherryPy 的请求和响应对象)写入访问日志。如果您要传递自己的 WSGI 应用程序,则必须进行自己的日志记录。

于 2013-08-08T14:39:09.160 回答