Page Summary
-
Google Ads API requests and responses can be logged using either a custom logger or the default client library logger in Perl.
-
The library logs successful API responses at INFO (summary) and DEBUG (full details), while logging API errors at WARN (summary) and INFO (full details).
-
The client library uses a
GoogleAdsLoggerclass with a default configuration that logs to files in alogsfolder, which can be customized with alog4perl.conffile. -
Logging can be enabled or disabled for summary and detail logs using specific methods of the
GoogleAdsLoggerclass.
Requests, responses, and summary messages made to the Google Ads API can be logged with your own custom logger or the default logger in the client library for Perl.
Log levels
The library logs different types of events to different log levels. On a
successful API response, the summary is logged at INFO, and the full
request and response are logged at DEBUG. On a request that results in
an API error, the summary message is logged at WARN and the full request
and response are logged at INFO.
| Log type | Log name | Success level | Failure level |
|---|---|---|---|
| SUMMARY | Google.Ads.GoogleAds.Summary | INFO | WARN |
| DETAIL | Google.Ads.GoogleAds.Detail | DEBUG | INFO |
For partial failures, the partial failure details are logged to the DETAIL
logger at DEBUG.
Configuration
The client library uses a custom class for all logging purposes and is exposed
through the GoogleAdsLogger module. This class provides a
default configuration where both summary and detail loggers write to files in
the logs folder under your HOME directory.
Customize Log4perl configuration
You can override the default configuration by providing a custom
log4perl.conf file in your HOME directory, or by
initializing Log::Log4perl directly in your application before making API
calls.
Enable or disable logs
Logging can be enabled or disabled programmatically using the following helper methods:
Enable logging for both loggers (pass
1to set the level toDEBUGso full request and response payloads are logged for successful calls):use Google::Ads::GoogleAds::Logging::GoogleAdsLogger; Google::Ads::GoogleAds::Logging::GoogleAdsLogger::enable_all_logging(1);Disable all logging:
Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_all_logging();Disable summary logging:
Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_summary_logging();Disable detail logging:
Google::Ads::GoogleAds::Logging::GoogleAdsLogger::disable_detail_logging();
You can use the methods of the GoogleAdsLogger class directly for even more
control over how requests are logged.