Reputation: 1232
I'm trying to remove logging from requests library. I tried everything on the web but I keep getting spam like this:
send: 'GET / HTTP/1.1\r\nHost: www.google.com\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.3.0 CPython/2.7.10 Darwin/15.2.0\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Cache-Control: private
header: Content-Type: text/html; charset=UTF-8
header: Location: https://www.google.pt/?gfe_rd=cr&ei=plwnV9OUHYas8wekio2ADw
header: Content-Length: 259
header: Date: Mon, 02 May 2016 13:56:54 GMT
send: 'GET /?gfe_rd=cr&ei=plwnV9OUHYas8wekio2ADw HTTP/1.1\r\nHost: www.google.pt\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.3.0 CPython/2.7.10 Darwin/15.2.0\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Mon, 02 May 2016 13:56:54 GMT
header: Expires: -1
header: Cache-Control: private, max-age=0
header: Content-Type: text/html; charset=ISO-8859-1
header: P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
header: Content-Encoding: gzip
header: Server: gws
header: X-XSS-Protection: 1; mode=block
header: X-Frame-Options: SAMEORIGIN
header: Set-Cookie: NID=79=OojMOTKzHw7ADN02S4j_nk-sRaWCeQ8P-JTKiCEarWlwIqzYnH2tP0GEVOov-Svl8Pn5-cMpv6sILvEKUaC0PayZe8PeAzN8uaqpTeDjJpka2KDjZyOSXig7bQBqw-mv; expires=Tue, 01-Nov-2016 13:56:54 GMT; path=/; domain=.google.pt; HttpOnly
header: Transfer-Encoding: chunked
And all of this is just for this line of code: requests.get('https://www.google.com', timeout=5)
My current settings is like this:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level': 'DEBUG',
'class': 'django.utils.log.NullHandler',
},
'console': {
# logging handler that outputs log messages to terminal
'class': 'logging.StreamHandler',
'level': 'WARNING', # message level to be written to console
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': False,
},
'django.db': {
'level': 'DEBUG',
'handlers': ['console'],
},
'boto': {
'level': 'CRITICAL',
'handlers': ['console'],
'propagate': False,
},
'requests.packages.urllib3': {
'level': 'WARNING',
'handlers': ['null'],
'propagate': False,
},
}
}
Is there anyway to remove this spam? I am getting this logging whenever I use boto s3 or the requests library. I already trying removing it with this settings, and with logging.disable(...) and logging.getLogger("urllib3").setLevel(logging.WARNING)
Upvotes: 0
Views: 346
Reputation: 1232
For those who want to ignore this same span adding the following line to the beginning of your file works just fine (not the best solution though):
httplib.HTTPConnection.debuglevel = 0
Upvotes: 1