1# Logging 2 3This page provides logging tips to help you debug your applications. 4 5## Log Level 6 7You can enable logging of key events in this library by configuring Python's standard [logging](http://docs.python.org/library/logging.html) module. You can set the logging level to one of the following: 8 9- CRITICAL (least amount of logging) 10- ERROR 11- WARNING 12- INFO 13- DEBUG (most amount of logging) 14 15In the following code, the logging level is set to `INFO`, and the Google Translate API is called: 16 17```python 18import logging 19from googleapiclient.discovery import build 20 21logger = logging.getLogger() 22logger.setLevel(logging.INFO) 23 24def main(): 25 service = build('translate', 'v2', developerKey='your_api_key') 26 print service.translations().list( 27 source='en', 28 target='fr', 29 q=['flower', 'car'] 30 ).execute() 31 32if __name__ == '__main__': 33 main() 34``` 35 36The output of this code should print basic logging info: 37 38``` 39INFO:root:URL being requested: https://www.googleapis.com/discovery/v1/apis/translate/v2/rest 40INFO:root:URL being requested: https://www.googleapis.com/language/translate/v2?q=flower&q=car&source=en&alt=json&target=fr&key=your_api_key 41{u'translations': [{u'translatedText': u'fleur'}, {u'translatedText': u'voiture'}]} 42``` 43 44## HTTP Traffic 45 46For even more detailed logging you can set the debug level of the [httplib2](https://github.com/httplib2/httplib2) module used by this library. The following code snippet enables logging of all HTTP request and response headers and bodies: 47 48```python 49import httplib2 50httplib2.debuglevel = 4 51```