-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Disable debug log messages #521
Comments
Can you provide a code snippet of how you are setting up your logger? There is not really any way we can stop boto3/botocore from logging the messages to the logger as that is hard coded, but you should be able to prevent the logger from printing the messages out depending on how your handlers on you logger is set. Otherwise, we are not doing anything special we are just using the builtin logger module: https://docs.python.org/2/library/logging.html#module-logging |
are you using a specific name for boto logger? so I can just get it using getLogger and remove the handlers or change it to be less verbose or redirecting it to a file |
Yeah for the logger, we default to |
thanks |
Each module in boto3 uses a different logger based on name. If you print the logging.Logger.manager.loggerDict after import, you can see a bunch of loggers were created like: ['nose.case', 'botocore.vendored.requests.packages', 'boto3.resources.collection', 'botocore.vendored.requests.packages.urllib3.util.retry', 'botocore.retryhandler', 'boto3', 'nose.proxy', 'botocore.utils', 'nose.loader', 'botocore.vendored.requests.packages.urllib3', 'botocore', 'botocore.vendored.requests.packages.urllib3.util', 'botocore.handlers', 'botocore.awsrequest', 'nose.config', 'botocore.credentials', 'botocore.hooks', 'botocore.parsers', 'botocore.response', 'nose.plugins.manager', 'pandas', 'botocore.endpoint', 'botocore.vendored.requests.packages.urllib3.poolmanager', 'botocore.waiter', 'boto3.resources.base', 'botocore.vendored', 'boto3.resources.model', 'boto3.resources.factory', 'nose.core', 'bcdocs', 'pandas.io.gbq', 'botocore.compat', 'boto3.resources', 'botocore.auth', 'boto3.resources.action', 'botocore.vendored.requests.packages.urllib3.connectionpool', 'nose.plugins', 'nose.importer', 'nose.failure', 'nose.result', 'botocore.vendored.requests', 'nose', 'nose.selector', 'nose.suite', 'botocore.client'] To increase the logging level, you would need to do that on all 3 top lvl loggers: logging.getLogger('boto3').setLevel(logging.WARNING) |
@edwardxwu may I use the same function (setLevel) to disable the logging? |
you can set it to a super high lvl like logging.CRITICAL or just disable the propagation to the root logger by logger.propagate = False |
@edwardxwu I tried your approach setting just CRITICAL level:
But I still see some logs from DEBUG level:
Update: I fixed this by adding |
@p1nox how did you find the name of the logger for s3tranfer? |
@soopanova and all that came here looking to disable log messages or set levels: import logging
loggers_dict = logging.Logger.manager.loggerDict |
Which leads me to...
|
End up with this...
|
If you want to make sure that the logging module only collects log from your classes, avoid using root loggers. Essentially, instead of importing loggers with |
It Works! Thx |
To expand on @parinpshah94 response. This is the recommended convention in the Python Logging docs.
|
import logging logging.getLogger('boto3').setLevel(logging.CRITICAL) |
May I suggest this:
|
Is there a way to disable or be less verbose ?
I'm using it in my celery task and boto3 is printing a lot of debug messages
The text was updated successfully, but these errors were encountered: