Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

cannot log google ads logging v19 python client

50 views
Skip to first unread message

Lộc Đoàn

unread,
May 12, 2025, 5:10:18 AMMay 12
to Google Ads API and AdWords API Forum
Hi Google Ads team,

Since upgrading Google Ads API version to v19, I cannot get the Google Ads logging.

```
import asyncio
import logging
from google.protobuf.json_format import MessageToDict

logging.basicConfig(level=logging.INFO, format='[%(asctime)s - %(levelname)s] %(message).5000s')
logging.getLogger('google.ads.googleads.client').setLevel(logging.INFO)

import google.ads.googleads.client


def setup_google_ads_connection():
google_ads_client = (
google.ads.googleads.client.GoogleAdsClient.load_from_storage("googleads.yaml")
)
ga_service = google_ads_client.get_service("GoogleAdsService", version="v19")
return google_ads_client, ga_service


async def main(google_ads_client, google_ads_service):
cust_list = ["2978713003"]
for cust_id in cust_list:
asset_query = "SELECT segments.date,campaign.id,ad_group.id,metrics.impressions,metrics.clicks,metrics.cost_micros,asset_field_type_view.field_type,metrics.video_views,metrics.cross_device_conversions FROM asset_field_type_view WHERE segments.date >= '2025-03-05' AND segments.date <= '2025-03-05' AND metrics.impressions > 0 AND campaign.id in ('21080449403')"
setting = google_ads_client.get_type('SummaryRowSettingEnum').SummaryRowSetting.SUMMARY_ROW_WITH_RESULTS
search_request = google_ads_client.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = cust_id
search_request.query = asset_query
search_request.summary_row_setting = setting
_CLIENT_TIMEOUT_SECONDS = 400
stream = google_ads_service.search_stream(
search_request,
timeout=_CLIENT_TIMEOUT_SECONDS
)
result = []
summary_result = []
for batch in stream:
summary_row = batch.summary_row
summary_row = MessageToDict(
summary_row,
use_integers_for_enums=False,
preserving_proto_field_name=True
)
summary_result.append(summary_row)
for row in batch.results:
row = MessageToDict(
row,
use_integers_for_enums=False,
preserving_proto_field_name=True
)
result.append(row)

if result:
print(f"{cust_id} has data")

if __name__ == "__main__":
google_ads_client, google_ads_service = setup_google_ads_connection()

asyncio.run(
main(google_ads_client, google_ads_service)
)


```

I use python 3.12.9
Here's the version of library used in python when pip freeze
aiohttp==3.9.5
aiosignal==1.3.2
attrs==25.3.0
boto3==1.34.126
botocore==1.34.126
cachetools==5.5.2
certifi==2025.1.31
charset-normalizer==3.4.1
frozenlist==1.6.0
google-ads==26.1.0
google-api-core==2.24.2
google-auth==2.39.0
google-auth-oauthlib==1.2.2
googleapis-common-protos==1.70.0
googlemaps==4.10.0
grpcio==1.71.0
grpcio-status==1.62.3
idna==3.10
iso3166==2.1.1
jmespath==1.0.1
multidict==6.4.3
numpy==2.2.5
oauthlib==3.2.2
pandas==2.2.2
propcache==0.3.1
proto-plus==1.26.1
protobuf==4.25.7
psycopg2-binary==2.9.10
pyasn1==0.6.1
pyasn1_modules==0.4.2
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
redis==5.1.1
requests==2.32.3
requests-oauthlib==2.0.0
rsa==4.9.1
s3transfer==0.10.4
six==1.17.0
tzdata==2025.2
ujson==5.10.0
urllib3==2.4.0
uvloop==0.19.0
yarl==1.20.0

P/S: when I use v17, the logging is normal.

Can you guide me through the steps to get Google Ads logging again?

Google Ads API and AdWords API Forum

unread,
May 12, 2025, 5:10:53 PMMay 12
to Google Ads API and AdWords API Forum
Hi,

Thank you for reaching out to the Google Ads API support team.

Please be informed that the library uses Python's built-in logging framework and logs to stderr by default. If included, the logging object defined in your configuration is passed directly to logging.config.dictConfig as a dict. You can also configure logging programmatically by setting a logging configuration before initializing the client. You can retrieve the client logger instance and configure it with the following example:

import logging

logging.basicConfig(level=logging.INFO, format='[%(asctime)s - %(levelname)s] %(message).5000s')
logging.getLogger('google.ads.googleads.client').setLevel(logging.INFO)

Note that the client logger is configured when the client is initialized. Any subsequent changes to the logging configuration will be ignored. I would recommend you refer to the guide Logging to get more information.

I hope this helps! If you need any further assistance, I recommend you reach out to the Python client library owners via this link, for further assistance.

Thanks & Regards,
Google Ads API support team.

Lộc Đoàn

unread,
May 12, 2025, 11:33:28 PMMay 12
to Google Ads API and AdWords API Forum
Hi Google Ads team,

I have read your logging doc and follow it. Can you give further assistance? 

Also, this only happens when I upgrade API to v19. When I downgrade to v17, the log is still fine.

Google Ads API and AdWords API Forum

unread,
May 13, 2025, 1:03:26 AMMay 13
to Google Ads API and AdWords API Forum

Hi,

I see that you are having issues with Google Ads API (Python client). I would recommend that you reach out to the Python Client Library owner by filing an issue in the issue tracker on the issues tab of your client library on GitHub, so that they can provide guidance on it.

Reply all
Reply to author
Forward
0 new messages