Skip to main content

[box-python-sdk-gen] What's the correct way to enable logging?


NickB

If I have my own logger+handler and not using BasicConfig… so like this…


chandler = logging.StreamHandler() 

chandler.setFormatter(logging.Formatter('[%(levelname)s] %(asctime)s %(message)s'))

logger = logging.getLogger("my_custom_logs")

logger.setLevel(logging.DEBUG)

logger.addHandler(chandler)


I’m getting weirdness with client.uploads.upload_file_version where it hangs for 10mins, then the created version is blank. It’s not throwing any Exceptions and nothing lands in my logger


What’s the correct way to get debug logs from the BoxClient?

2 replies

rbarbosa Box
  • Developer Advocate
  • 553 replies
  • May 20, 2024

Hi @NickB , welcome to the forum!!!


I typically do something like this:


logging.getLogger("box_sdk_gen").setLevel(logging.CRITICAL)


Let us know if this helps.


  • Participating Frequently
  • 15 replies
  • May 28, 2024

Hi,

currently box_sdk_gen doesn’t have any dedicated logger, but you can use one provided by requests library. To enable logging of all requests and responses use this snippet:


from urllib3.connection import HTTPConnection



HTTPConnection.debuglevel = 1

logging.getLogger().setLevel(logging.DEBUG)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings