Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What can I do to stop the logs information of a client from box-python-sdk? #414

Closed
1 task done
c-rei opened this issue Mar 26, 2019 · 11 comments
Closed
1 task done

Comments

@c-rei
Copy link

c-rei commented Mar 26, 2019

Description of the Issue

// Replace this text with a description of what problem you're having.
// Please include as much detail as possible to help us troubleshoot!
// If it isn't obvious, please include how the behavior you expect differs from what actually happened.
// This is really important so we know how to start troubleshooting your issue.

Versions Used

Box Python SDK: // Replace with the version of the Python SDK you're using.
Python: // Replace with the version of Python your application is running on.

Steps to Reproduce

// Please include detailed steps to reproduce the issue you're seeing, if possible.
// If you don't have a reproducible error, please make sure that you give us as much detail
// as you can about what your application was doing when the error occurred.
// Good steps to reproduce the problem help speed up debugging for us and gets your issue resolved sooner!

Error Message, Including Traceback

// Replace with the full error output you're seeing, if applicable.
// Please include the full stack trace to help us identify where the error is happening.

@carycheng
Copy link

Hey @c-rei,

In order to get a little more context around your problem, could you please fill out the Github issue template provided? Much appreciated!

At a high level, my first thought would be to ask which client you are using? If you are setting up a client like so:

auth = OAuth2(client_id='CLIENT_ID', client_secret='CLIENT_SECRET', access_token='ACCESS_TOKEN')
client = Client(auth)

Then there should be no reason why you are seeing logs as logs are not turned on by default.

However, the issue template would be very helpful, thank you!

@c-rei
Copy link
Author

c-rei commented Apr 2, 2019

Hey carycheng,

Thanks for your responses.

Yes, as you guessed, I used auth = OAuth2(client_id='CLIENT_ID', client_secret='CLIENT_SECRET', ... with box python sdk 2.2.1. When I've used box python sdk 1.5.5, I don't get any logs from box python sdk.
So I want to stop it if our users want to do.

The logs likes below,

2019-04-02 10:27:12,186 - INFO �[36mGET https://api.box.com/2.0/users/me {'headers': {'Authorization': '---wVjT',
'User-Agent': 'box-python-sdk-2.2.1',
'X-Box-UA': 'agent=box-python-sdk/2.2.1; env=python/3.6.8'},
'params': None}�[0m
2019-04-02 10:27:13,091 - WARNING �[31m"GET https://api.box.com/2.0/users/me" 401 0
{'Date': 'Tue, 02 Apr 2019 01:27:13 GMT', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000', 'WWW-Authenticate': 'Bearer realm="Service", error="invalid_token", error_description="Th
e access token provided is invalid."', 'BOX-REQUEST-ID': '0jkg2p6qt8j9ivoc4no2i415aq5', 'Age': '1'}
b''

@carycheng
Copy link

Hey @c-rei,

Did you at any point use the DevelopmentClient to instantiate a client? If so the SDK remembers that logging is set up and will continue to log even after you switch back to using a regular Client.

To fix this a good thing to try would be to revoke the current client and re-instantiate a new Client making sure that this is the only client you have set up.

How this works currently is that the DevelopmentClient inherits from LoggingClient and DeveloperTokenClient. Inside LoggingClient we call the method setup_logging() which activates logging globally.

@c-rei
Copy link
Author

c-rei commented Apr 8, 2019

Hey @carycheng

At some point I used the DevelopmentClient probably, so I tried to reset token, and re-instantiate a new Client, But I still received the logs like below with SDK 2.2.1.

HTTP/1.1" 200 0
2019-04-08 09:22:30,714 - INFO �[36mPOST https://api.box.com/oauth2/token {'data': {'box_device_id': '0',
'client_id': '---kq1h',
'client_secret': '---XTIa',
'code': '---n2Yx',
'grant_type': 'authorization_code'},
'headers': {'User-Agent': 'box-python-sdk-2.2.1',
'X-Box-UA': 'agent=box-python-sdk/2.2.1; env=python/3.6.8',
'content-type': 'application/x-www-form-urlencoded'}}�[0m
2019-04-08 09:22:31,568 - INFO �[32m"POST https://api.box.com/oauth2/token" 200 193
{'Date': 'Mon, 08 Apr 2019 00:22:31 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip', 'Strict-Transport-
Security': 'max-age=31536000', 'Set-Cookie': 'box_visitor_id=5caa94471d6ed3.05350285; expires=Wed, 08-Apr-2020 00:22:31 GMT; Max-Age=31622400; path=/; domain=.box.com; secure, bv=OPS-42970; expires=Mon, 15-Apr-2019 00:22:31 GMT; Max-Age=604
800; path=/; domain=.app.box.com; secure, cn=80; expires=Wed, 08-Apr-2020 00:22:31 GMT; Max-Age=31622400; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure'}

@c-rei
Copy link
Author

c-rei commented Apr 8, 2019

Hey @carycheng

When I upload a big file with my application, I got a serious problem that is the huge logs for a big file go on the prompt, it truly impact my application's performance.

When I use SDK ver. 1.5.5 I didn't get any logs, but when I use SDK ver. 2.x.x I got the logs from SDK. So I think the new version SDK has some modifications for client logs. I really want to stop it.

@c-rei
Copy link
Author

c-rei commented Apr 8, 2019

Hey @carycheng

The logs like this:
b'\xae;\x81\x1a\x95o\xf5\xec\xf9d\xa1A+\xe1\x9e\xfc\xbb\xec\xc3\xc6'
b'q\x19\x1aU\x03\xae\xf9\x11X\x17n\xe8\xd9I\xebr7\x85\xda\x9f'
b'T\x14y\xc8\xe1\x9c\xc6V\xc4\x92&\xb2\x86\x085!I\x1b}e'
b'\xf3\x92\x97\xfbU\x01\x1c{D\x03n\x0f\x9b\xd3\xb9h,Y\n\x1at\a!'
b'\xb3\x8f\xfe\xcd$\x82Z\xff\x942xq+\xd1\x9a\xb6J\xbdH)'
b'\x01\xf5\xf9\x02\x95\xf4D\x84\x9bC\xfa\xf2\x0b\x13\xd2\x99Qm\xf4\x10'
b'\x0f\xeb\x0c\x8f!\xf5l\xd9\xdd\xe2.\xe3\xd1\xe5\xaf\xcfQ\x19\x87'
b'\x1b\x9d\x99\xbb\xfa\x0e\n\xd6M9\xce\xac\x81Y\xb7\x974\x94^\xba'
b'\xa7K\x0e+J\xb9\x99y\xed\x1c\xb3\x14\xc7t\x16\xa2\xaej\xbbs'
b'\xf1\xdflR2\x8a/ff\xdeY\xe8,\xd0\xcc\x03t4\x10\xa3\x88\xcb\xb3\x9d'
b'$`\x12=\xa0\xf0\xb8EFY\xb6\x87\xce\x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xf9\xc2\xa0J\xdf\x1fb\xc8OGM \x99 W\x9f\xe4F \x05\xe4NK'
b'\xbcI\xb0C]\xd6\xf6\xa6q\xb2\x95\xbb3f)\x1e\xcd\r\xea$b\xe9\xcd\xc6'
b'.\x1dA\xfe\x1f\x19@\xb6\x03>\xa6\xf1\x9f\xbc\xe2\xc7u5\xcb\r\xec8@7'

@c-rei
Copy link
Author

c-rei commented Apr 8, 2019

Hey @carycheng

I've known the reason of this problem.
Because I use a python standard logger in my applications like below, the new version SDK just use my root logger. (I tried to change the logger format, the log messages changed)

logging.config.fileConfig(resource_path('logging.conf'), defaults={'logfile': resource_path('error.log')})
logger1 = logging.getLogger('root')
logger2 = logging.getLogger('Log4Python')

But I don't known how to resolve this, could you give me any advice?

@carycheng
Copy link

Hey @c-rei,

Can you try this in your application?

logging.getLogger('boxsdk').setLevel(logging.CRITICAL)

This should silence the SDK logging.

Let us know if this helps, thanks!

@c-rei
Copy link
Author

c-rei commented Apr 12, 2019

Hey @carycheng

Thanks your response for me. I tried to set logging level that you told me.

It silenced the SDK logging fine.

Thanks for your helps.

@carycheng
Copy link

Glad to hear @c-rei!

I'll be closing this issue for now, please feel free to reopen if this problem persists or create a new issue if you come across any other questions, thanks!

@benshanahan1
Copy link

Hi, I'm running into the same issue as @c-rei. It is fixed by adding the following line as suggested:

logging.getLogger('boxsdk').setLevel(logging.CRITICAL)

However, I would like to have the logging turned off without having to include this line. @carycheng you mention that the SDK remembers that the DevelopmentClient was previously used and that the only way to forget this is to "revoke" the client. Can you provide more information on how to do this?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants