Control wsgiref simple_server log
wsgiref.simple_server.make_server
by default creates a WSGIServer
with WSGIRequestHandler
:
def make_server(
host, port, app, server_class=WSGIServer, handler_class=WSGIRequestHandler):
"""Create a new WSGI server listening on `host` and `port` for `app`"""
server = server_class((host, port), handler_class)
server.set_app(app)
return server
WSGIRequestHandler
here extends from BaseHTTPServer.BaseHTTPRequestHandler
, where the logging magic turns out to be:
def log_message(self, format, *args):
sys.stderr.write("%s - - [%s] %s\n" %
(self.client_address[0],
self.log_date_time_string(),
format%args))
So it's logging to stderr, actually, not to python logging module. You can override this in your own handler:
class NoLoggingWSGIRequestHandler(WSGIRequestHandler):
def log_message(self, format, *args):
pass
And pass your custom handler to the server instead:
httpd = make_server('', 8000, application, handler_class=NoLoggingWSGIRequestHandler)