How to disable DEBUG: messages in the console when the program is running?

zz1424
How to disable DEBUG: messages in the console when the program is running?

  • rakeshr
    These are python debug logs. You can remove the required part logging.basicConfig(level=logging.DEBUG), to disable this.
  • zz1424
    Hi, remove from where exactly? I do not see this code anywhere in my program.
  • rakeshr
    DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.kite.trade
    These are Debug level logging. Can you re-check, if you are using the logging module in your code?
  • zz1424
    Not at all. There is zero mention of this in my codes.
  • rakeshr
    Can you paste your complete code for the same? We will take look at it.
  • ni5h
    @rakeshr - I am facing the same issue. Your below suggestion works when I am running the same module but when I am import the module in another module I still get DEBUG logs from matplotlib. I tried searching on google but none of the answers worked for me. Can you please please help me here.

    logging.basicConfig(level=logging.DEBUG)
  • SRIJAN
    KiteConnect python client doesn't use matlplotlib.

    I have a feeling you are not using the KiteConnect APIs , actually you have come on this forum from the google search.

    If so,then we only deal with technical queries related to KiteConnect APIs on this forum,not other programming related stuff.

    Still,for this time,I will try to help you.
    I don't exactly get your query.

    But,this should help:

    import logging
    logging.getLogger('matplotlib').propagate=False
  • ni5h
    Thanks @SRIJAN . I am using KiteConnect python library.

    My guess is KiteConnect might not be using matplotlib directly but one of the dependencies must be using.

    I tried your suggestion (below code) in the script where I am importing my custom module but it is still showing me DEBUG logs.
    import logging
    logging.getLogger('matplotlib').propagate=False


    To elaborate what I am doing :
    I have py1 something like below

    from kiteconnect import KiteConnect
    import pandas as pd
    import yaml

    logging.basicConfig(level=logging.DEBUG)

    class Zerodha:
    def __init__(self):
    # my code here

    deffunction1(self):
    # my code here


    I am importing class Zerodha in py2

    from py1 import Zerodha


    When I run py2 I get Matplotlib DEBUG logs where as when py1 is run I dont get logs.

    There are solutions available on stackoverflow to suppress the DEBUG logs coming from Matplotlib but they doesnt work for me.

    Any help is appreciated.
  • SRIJAN
    SRIJAN edited August 30
    No, KiteConnect python client doesn't use matplotlib at all.

    You can view all the dependencies here:
    https://github.com/zerodha/pykiteconnect/blob/8e36dde9fe34bb0c7c5677a4dc0fb0b1beb40787/setup.py#L44

    This is only possible when you are importing matlplotlib in py2.

    Not sure why it doesn't work for you,but the solution I gave earlier works for me.

    And because you are not using if __name__ == "__main__",the logging part is being imported too with the 'Zerodha' class.

    Try to put logging part under if __name__ == "__main__" in py1.

    Actually you can just remove the logging part if you don't want logs ,as Rakesh Sir told above,to stop these logs.

    Still,if the problem isn't resolved,write on relevant forums.
    We can't help anymore as we don't provide programming support on this forum.

    This forum is purely dedicated to technical queries related to KiteConnect APIs.
Sign In or Register to comment.