define logFilePath as environment variable

98 views
Skip to first unread message

Robert Zimmermann

unread,
Nov 16, 2021, 8:25:53 AM11/16/21
to AdWords API and Google Ads API Forum

Google Ads API Forum Advisor

unread,
Nov 16, 2021, 11:19:51 AM11/16/21
to taylor8...@gmail.com, adwor...@googlegroups.com
Hi Robert,

There's no documented support to define the logFilePath as environment variable in our PHP client library. Could you state in business terms your use case?

Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey

Regards,
 
Google Logo
Aryeh Baker
Google Ads API Team
 


ref:_00D1U1174p._5004Q2R9S88:ref

Robert Zimmermann

unread,
Dec 2, 2021, 4:35:09 AM12/2/21
to AdWords API and Google Ads API Forum
Depending on the environment, we want to be able to change the logFilePath and logLevel.
Both are part of google_ads_php.ini so it would be logical if this can also be set via the environment variable.

I have now found a solution:

// Binds the Google Ads API client.
$this->app->singleton('Google\Ads\GoogleAds\Lib\V9\GoogleAdsClient', function () {
// Constructs a Google Ads API client configured from the properties file.
return (new GoogleAdsClientBuilder())
->withLogger((new LoggerFactory())
->createLogger('google-ads', config('googleads.log_file_path'), config('googleads.log_level')))
->withOAuth2Credential((new OAuth2TokenBuilder())
->fromEnvironmentVariables()
->build())
->fromEnvironmentVariables()
->build();
});

Google Ads API Forum Advisor

unread,
Dec 2, 2021, 10:30:22 PM12/2/21
to taylor8...@gmail.com, adwor...@googlegroups.com
Hi Robert,

I am happy to know that you've found a solution. I am also a member of the Google Ads API team and let me provide support to your concern.

Alternatively, you may follow this guide as it explains how to log API transactions for PHP client library as well as updating the setting of logFilePath.

Let me know if you have further questions.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


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