環境: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