环境:Windows 7 64bit,Python版本3.2.5,使用PyWin32-218和cherrypy 3.6.0版。CherryPy沉默日志记录在Windows服务上不起作用
我复制了CherryPy as a Windows Service的windows服务示例(CP 3.1),发现服务几乎立即启动和停止。一些摆弄后,我创建了一个静态的日志文件中写入调试(因为服务差异目录比原来的脚本运行),并得到这个:
>[05/Feb/2015:16:29:05] ENGINE Bus STARTING
>[05/Feb/2015:16:29:05] ENGINE Error in 'start' listener <cherrypy._cpchecker.Checker object at 0x0000000002556278>
>Traceback (most recent call last):
> File "C:\Python32\lib\site-packages\cherrypy\process\wspbus.py", line 205, in publish
> output.append(listener(*args, **kwargs))
> File "C:\Python32\lib\site-packages\cherrypy\_cpchecker.py", line 39, in __call__
> method()
> File "C:\Python32\lib\site-packages\cherrypy\_cpchecker.py", line 176, in check_static_paths
> % (msg, section, root, dir))
> File "C:\Python32\lib\warnings.py", line 18, in showwarning
> file.write(formatwarning(message, category, filename, lineno, line))
>AttributeError: 'NoneType' object has no attribute 'write'
>
>[05/Feb/2015:16:29:05] ENGINE Started monitor thread '_TimeoutMonitor'.
>[05/Feb/2015:16:29:05] ENGINE Serving on http://0.0.0.0:8080
>[05/Feb/2015:16:29:05] ENGINE Shutting down due to error in start listener:
>Traceback (most recent call last):
> File "C:\Python32\lib\site-packages\cherrypy\process\wspbus.py", line 243, in start
> self.publish('start')
> File "C:\Python32\lib\site-packages\cherrypy\process\wspbus.py", line 223, in publish
> raise exc
>cherrypy.process.wspbus.ChannelFailures: AttributeError("'NoneType' object has no attribute 'write'",)
>
>[05/Feb/2015:16:29:05] ENGINE Bus STOPPING
>[05/Feb/2015:16:29:06] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8080)) shut down
>[05/Feb/2015:16:29:06] ENGINE Stopped thread '_TimeoutMonitor'.
>[05/Feb/2015:16:29:06] ENGINE Bus STOPPED
>[05/Feb/2015:16:29:06] ENGINE Bus EXITING
>[05/Feb/2015:16:29:06] ENGINE Bus EXITED
Google搜索错误,发现这个running CherryPy 3.2 as a Windows service谁了完全相同的错误。 做了更多的研究,看到windows服务的控制台输出指向'Nothing'。 所以我加sys.stdout = open('stdout.log', 'a+')
和sys.stderr = open('stderr.log', 'a+')
只是之前cherrypy.engine.start()
和你知道,它的作品!
但是现在我想让CherryPy不要登录。 尝试了各种配置设置和代码例如:log.screen = None
和server.log_to_screen = False
和checker.check_skipped_app_config = False
,甚至导致业务关闭,并给予同样的错误如上
logger = cherrypy.log.access_log
logger.removeHandler(logger.handlers[0])
他们没有工作。
我是否错过了一些东西,或者真的不可能让记录沉默?
非常感谢!就像一个白痴,我在文档搜索,但在错误的部分和搜索条件。 – MVorster 2015-02-06 06:39:48