Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should aiohttp also logging websocket? #5586

Open
NewUserHa opened this issue Apr 2, 2021 · 9 comments
Open

should aiohttp also logging websocket? #5586

NewUserHa opened this issue Apr 2, 2021 · 9 comments

Comments

@NewUserHa
Copy link
Contributor

🐣 Is your feature request related to a problem? Please describe.
no

💡 Describe the solution you'd like
aiohttp won't log any websocket access log except it will log error 400 for a GET.

should aiohttp log websocket when established? or when every message sent and received?

Describe alternatives you've considered
no

📋 Additional context
na

@anesabml
Copy link
Contributor

anesabml commented Apr 5, 2021

@NewUserHa could you please add the steps to reproduce your issue? aiohttp uses the standard logging module, maybe try setting the logging level to logging.DEBUG like so: logging.basicConfig(level=logging.DEBUG)

@NewUserHa
Copy link
Contributor Author

don't have the code now.
you just need use logging.basicConfig(level=logging.DEBUG) and the code for ws in aiohttp's doc. and use aiohttp's client to connect to that ws. the server will log nothing for that connection.

@anesabml
Copy link
Contributor

anesabml commented Apr 5, 2021

@NewUserHa I am sorry for the missunderstanding. Yes, the server will only log a warning when subscribing to the aiohttp.websocket logger. As of right now there's no support for logging when a connection is established, I am not sure if that's the library responsibility or not.

@NewUserHa
Copy link
Contributor Author

what warning did you see? If you connect to aiohttp via ws client, there's nothing being logged.
but if you use http to connect, there's a warning 400

@anesabml
Copy link
Contributor

anesabml commented Apr 5, 2021

@NewUserHa it will display a warning when the client protocols don’t overlap server-known ones when establishing a connection.

@NewUserHa
Copy link
Contributor Author

that's right.
then it won't log anything like {time} 200 etc., if a ws client successfully connected.

@anesabml anesabml added the server label Apr 6, 2021
@anesabml
Copy link
Contributor

anesabml commented Apr 6, 2021

@NewUserHa As of right now I think the only solution is to manually add logging statements, you can check out the chat demo for an example.

@NewUserHa
Copy link
Contributor Author

ok. checked that.
can put a log after prepare for temporary working around.

@webknjaz
Copy link
Member

webknjaz commented Apr 7, 2021

I see why this feature idea may be useful. Although, unlike normal HTTP, WebSocket connections are long-living. In the case of HTTP, the access log entries are emitted upon sending the HTTP responses (and include the response details). I suppose it's okay to have connect/disconnect logs but it's important to understand that any excessive logging to stdout/stderr hurts performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants