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

zljubisicmob at gmail.com zljubisicmob at gmail.com
Sat Apr 4 09:07:12 EDT 2015


Hi,

if I execute:

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').setLevel(logging.ERROR)
url = 'http://radio.hrt.hr/prvi-program/arhiva/povijest-cetvrtkom/126/'
wpage = requests.get(url)

the obrisi.log has the following contents:

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

>From requests module, I would like to log from error level above.

How to achieve that (raspberry pi 2, osmc, python 3.4.2?

Regards.



More information about the Python-list mailing list