How to enable logging for google-cloud-cpp sdk

368 views Asked by At

I'm using google-cloud-cpp SDK from here: https://github.com/googleapis/google-cloud-cpp. However, I can't seem to figure out how to enable logging for the client library and find out where the log file goes. I'm interested in seeing all the HTTP requests being made to the endpoint. Appreciate any help and/or examples.

1

There are 1 answers

2
coryan On BEST ANSWER

You need to set two environment variables:

  • GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes will redirect the logs to std::clog, the library does not create a log backend otherwise.
  • CLOUD_STORAGE_TRACING=http,raw-client otherwise logging is not even turned on.

You can find more information about environment variables for the SDK in the API Notes section of: https://googleapis.dev/cpp/google-cloud-storage/latest/index.html