Skip to main content
NickB
New Participant
May 16, 2024 1:59 PM UTC

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

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
May 20, 2024 6:07 PM UTC

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.

Translate
Box Employee
May 28, 2024 1:59 PM UTC

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)
Translate