Environment: Windows 7 64bit, Python version 3.2.5 with PyWin32-218 and cherrypy version 3.6.0.
I copied the windows service example (CP 3.1) from CherryPy as a Windows Service and found out that the service starts and stops almost immediately. After some fiddling I created a static log file to write to for debugging(because services run in diff directory than original script) and got this:
>[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
Googled the error and found this running CherryPy 3.2 as a Windows service who had precisely the same error.
Did some more research and saw that windows services' console output points to 'Nothing'.
so I added sys.stdout = open('stdout.log', 'a+')
and sys.stderr = open('stderr.log', 'a+')
just before cherrypy.engine.start()
and what do you know, it works!
BUT now I want CherryPy to not log at all.
Tried various config settings and code eg.:log.screen = None
and server.log_to_screen = False
and checker.check_skipped_app_config = False
and even
logger = cherrypy.log.access_log
logger.removeHandler(logger.handlers[0])
None of them work resulting in the service stopping and giving the same error as above.
Am I missing something or is it truly impossible to silence the logging?