How to set request module logging to certain level (python 3.4.2)

zljubisicmob at gmail.com zljubisicmob at gmail.com
Sat Apr 4 14:29:53 EDT 2015


On Saturday, April 4, 2015 at 5:23:02 PM UTC+2, Dennis Lee Bieber wrote:

> implies the correct name to use for the logger is
> "requests.packages.urllib3".

I have changed a script log_test.py. Now it looks like this:

#!/usr/bin/python3

import logging, requests
logging.basicConfig(filename="obrisi.log", level=10, format='%(asctime)s %(levelname)s %(message)s',datefmt='%d.%m.%Y %H:%M:%S')

logging.getLogger('requests.packages.urllib3').setLevel(logging.ERROR)

url = 'http://radio.hrt.hr/prvi-program/arhiva/povijest-cetvrtkom/126/'

def abc():
	wpage = requests.get(url)
	
	
wpage = requests.get(url)
abc()

from linux shell I am running it as:

rm obrisi.log; ./log_test.py; cat obrisi.log

the output is:

04.04.2015 20:29:05 INFO Starting new HTTP connection (1): radio.hrt.hr
04.04.2015 20:29:05 DEBUG "GET /prvi-program/arhiva/povijest-cetvrtkom/126/ HTTP/1.1" 200 None
04.04.2015 20:29:05 INFO Starting new HTTP connection (1): radio.hrt.hr
04.04.2015 20:29:05 DEBUG "GET /prvi-program/arhiva/povijest-cetvrtkom/126/ HTTP/1.1" 200 None
o

As you can see, it still doesn't work.
I really don't get it. I am confused. :(

Regards.



More information about the Python-list mailing list