[Python] How to suppress logging statements from third party libraries? [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 2, 2025.

  1. Stack

    Stack Membro Participativo

    My logging settings look like

    import requests
    import logging

    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger('BBProposalGenerator')


    When I run this, I get logs as

    INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localhost
    INFO:BBProposalGenerator:created proposal: 763099d5-3c8a-47bc-8be8-b71a593c36ac
    INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localhost
    INFO:BBProposalGenerator:added offer with cubeValueId: f23f801f-7066-49a2-9f1b-1f8c64576a03
    INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localhost
    INFO:BBProposalGenerator:evaluated proposal: 763099d5-3c8a-47bc-8be8-b71a593c36ac


    How can I suppress the log statements from requests package? so that I only see logs from my code

    INFO:BBProposalGenerator:created proposal: 763099d5-3c8a-47bc-8be8-b71a593c36ac
    INFO:BBProposalGenerator:added offer with cubeValueId: f23f801f-7066-49a2-9f1b-1f8c64576a03
    INFO:BBProposalGenerator:evaluated proposal: 763099d5-3c8a-47bc-8be8-b71a593c36ac

    Continue reading...

Compartilhe esta Página