Python-socketio: Can't disable logger in Server

Created on 20 Jan 2020  路  8Comments  路  Source: miguelgrinberg/python-socketio

How can I disable logger in socketio server to avoid getting outputs like this?

I know logger and engineio_logger are set to False by default but I keep getting these logs even when I manually set them to False.

11888e77e2464b3f8adc956f2d3cdd7d: Received packet PING data None
11888e77e2464b3f8adc956f2d3cdd7d: Sending packet PONG data None
127.0.0.1 - - [20/Jan/2020 19:32:32] "POST /socket.io/?transport=polling&EIO=3&sid=11888e77e2464b3f8adc956f2d3cdd7d HTTP/1.1" 200 167 0.000902
127.0.0.1 - - [20/Jan/2020 19:32:32] "GET /socket.io/?transport=polling&EIO=3&sid=11888e77e2464b3f8adc956f2d3cdd7d&t=1579536127.6851416 HTTP/1.1" 200 183 24.977945

question

All 8 comments

Are you passing the logger and engineio_logger options? If you are, then remove them. If you are not passing them and you still get logs, then you need to adjust the logging level of the logger that you configured in your own application.

Are you passing the logger and engineio_logger options? If you are, then remove them. If you are not passing them and you still get logs, then you need to adjust the logging level of the logger that you configured in your own application.


import logging
default_logger = logging.getLogger('tunnel.logger')
default_logger.setLevel(logging.CRITICAL)
default_logger.disabled = True

self.socket = Server(logger=default_logger,
                    engineio_logger=default_logger)

but still I get logs like this:
127.0.0.1 - - [22/Jan/2020 16:17:07] "GET /socket.io/?transport=polling&EIO=3&t=1579697227.7186677 HTTP/1.1" 200 349 0.000916

What web server are you using?
This is logging that comes from the web server, not from this package.

Same issue here .. any hints on how the logging can be disabled. I'm using socketio.WSGIApp as web server

@rkachach WSGIApp is a WSGI application wrapper, not a web server. What web server are you running on?

Thanks for the quick response. This is the code I have right now .. so I can't see any "web serving" functionality besides the WSGI.

import eventlet
import socketio

sio = socketio.Server()
app = socketio.WSGIApp(sio, static_files={'/': {'content_type': 'text/html', 'filename': 'index.html'}})

@sio.event
def connect(sid, environ):
    pass

@sio.event
def disconnect(sid):
    pass

if __name__ == '__main__':
    eventlet.wsgi.server(eventlet.listen(('', 5000)), app)

I want to disable logs such as:

127.0.0.1 - - [09/Jul/2020 13:13:54] "GET /socket.io/?transport=polling&EIO=3&t=1594293234.261398 HTTP/1.1" 200 349 0.001095
127.0.0.1 - - [09/Jul/2020 13:13:54] "POST /socket.io/?transport=polling&EIO=3&sid=84abac80c875421d971d3c9e53f0102d HTTP/1.1" 200 167 0.000459

I've tried to create the socketio.Server() with logger=False argument and tried also to disable the logger by using:

requests_log = logging.getLogger("socketio")
requests_log.setLevel(logging.ERROR)

But the logs are still there and I can't get rid of them ..

Your web server is provided by the eventlet package. You are starting the server in the last line of your application. Here is the documentation, including how to enable/disable logging: https://eventlet.net/doc/modules/wsgi.html.

Awesome, thank you very much for the information. I was a little bit lost, following the link you provided I managed to disabled it by adding log_output=False to the eventlet launching line, so new code is as following. Now I just see the logs coming from socketio :)

eventlet.wsgi.server(eventlet.listen(('', 5000)), app, log_output=False)

Was this page helpful?
0 / 5 - 0 ratings