Welcome, guest | Sign In | My Account | Store | Cart

Python's logging allocates a name to every logger. That makes it hard to do something like, setting everything to logging.ERROR. Here's one way you might go about that:

Python, 6 lines
1
2
3
4
5
6
for _name, logger in logging.Logger.manager.loggerDict:
    try:
        logger.setLevel(logging.ERROR)
    # skip "PlaceHolder" loggers
    except AttributeError:
        pass