Enable debug logs

websockets logs events with the logging module from the standard library.

It emits logs in the "websockets.server" and "websockets.client" loggers.

You can enable logs at the DEBUG level to see exactly what websockets does.

If logging isn’t configured in your application:

import logging

logging.basicConfig(
    format="%(asctime)s %(message)s",
    level=logging.DEBUG,
)

If logging is already configured:

import logging

logger = logging.getLogger("websockets")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())

Refer to the logging guide for more information about logging in websockets.

You may also enable asyncio’s debug mode to get warnings about classic pitfalls.