Google Ads API v9 (PHP) Logger not working

318 views
Skip to first unread message

Rachel Suddeth

unread,
Feb 14, 2022, 11:27:07 AM2/14/22
to Google Ads API and AdWords API Forum
I have tried to add a logger to my service client, but not seeing any messages. I am initializing the client like so:
```
protected function createGaClient($clientCustomerId, $loginClientCustomerId,
                                      $refreshToken, $oauth2Info, $devToken, $withLogger = true)
    {
        $oauth2Credentials = (new gaTokenBuilder())
            ->withClientId($oauth2Info['client_id'])
            ->withClientSecret($oauth2Info['client_secret'])
            ->withRefreshToken($refreshToken)
            ->build();

        $builder = (new GoogleAdsClientBuilder())
            ->withOAuth2Credential($oauth2Credentials)
            ->withDeveloperToken($devToken)
            ->withLoginCustomerId($loginClientCustomerId);
        if ($clientCustomerId != $loginClientCustomerId) {
            $builder->withLinkedCustomerId($clientCustomerId);
        }
        if ($withLogger) {
            $builder->withLogger(new Ibp_PsrLogger());
            $builder->withLogLevel('DEBUG');
        }

        $this->gaClient = $builder->build();
    }
```

I can successfully use this client to create a ConversionAction in my Google Ads account. The logger class is a simple wrapper around the logger we use for everything in our application. It is the same one we previously used for Adword API in this way:
```
 $builder = (new AdWordsSessionBuilder())
        ->withDeveloperToken($devToken)
        ->withUserAgent('DialogTech AdWords Integration')
        ->withClientCustomerId($clientCustomerId)
        ->withOAuth2Credential($oauth2Credentials);

    if ($withSoap) {
        $builder->withSoapLogger(new Ifbyphone_SoapLogger());
    }
    $this->awSession = $builder->build();
```

I definitely saw SOAP messages coming through our logs (last week) before I made the change over to the Google Ads API.
Any thoughts?
Message has been deleted

Rachel Suddeth

unread,
Feb 14, 2022, 11:30:37 AM2/14/22
to Google Ads API and AdWords API Forum
It might help to mention I had the following "use" statements:
use Google\AdsApi\Common\OAuth2TokenBuilder as awTokenBuilder;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;

use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder as gaTokenBuilder;
use Google\Ads\GoogleAds\Lib\V9\GoogleAdsClientBuilder;

Google Ads API Forum Advisor

unread,
Feb 15, 2022, 9:46:40 AM2/15/22
to adwor...@googlegroups.com
Hi Rachel,

Thanks for reaching out. As this issue is specific to the PHP Client Library, can you please try bringing up this issue to the Client Library owners, here?

Thanks,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2WvVTp:ref
Reply all
Reply to author
Forward
0 new messages