Is there a way to disable Pyrogram logging?

Viewed 308

I'm using this library only for couple methods, and it's kinda annoying that it's printing a lot of logs beside my own initialization logs.

Tried to get same logger as library gets, "pyrogram.client", and change it's level - nothing changed. Also logger.propagate = false doesn't help.

My friend got no logs from pyrogram by default, though our logger and pyrogram configs are the same.

2 Answers

A way to go, if you do not want to suppress other loggers:

import logging
for name, logger in logging.root.manager.loggerDict.items():
    if name.startswith('pyrogram'):
        logger.setLevel(logging.WARNING)

Optionally, if that's not enough, replace WARNING with ERROR or CRITICAL.

Related