Logging

  • The PHP client library uses PSR-3 for logging gRPC calls, with log levels varying based on success or failure of the event.

  • By default, logs are written to STDERR using a Monolog StreamHandler with configurable options in the google_ads_php.ini file.

  • For advanced customization, developers can implement the LoggerInterface and provide their own logger to the GoogleAdsClientBuilder.

  • Logging is currently not supported for REST calls.

The PHP client library conforms to PSR-3 for logging and provides a logger for gRPC calls.

The level at which messages are logged depends on whether the event succeeded.

Log message Success status Failure status
One-line summary INFO WARNING
Debug message (e.g., call queries) DEBUG NOTICE

Configuring logging

By default, each of the library loggers logs to STDERR on a channel with default name specified here using a Monolog StreamHandler.

You can configure some options for the default logger in the google_ads_php.ini file:

[LOGGING] ; Optional logging settings. logFilePath = "path/to/your/file.log" logLevel = "INFO"

If you need to further customize logging, you can specify your own logger entirely by providing a logger that implements the LoggerInterface in GoogleAdsClientBuilder:

$googleAdsClient = (new GoogleAdsClientBuilder())
    ...
    ->withLogger(new MyCustomLogger())
    ->build();