# Environment Variables

3.7.0-rc 3.6.0 (latest) 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 A number of environment variables can be used to configure the behavior of the library. There are also functions to configure this behavior in code. The environment variables are convenient when troubleshooting problems.

## Setting the Default Project

Some of the GCS APIs need a [project](https://cloud.google.com/storage/docs/projects) as a parameter. For such APIs the application can (a) call an overload that takes the project id as a parameter, (b) define the project explicitly when the `Client` object is constructed, or (c) set the `GOOGLE_CLOUD_PROJECT` environment variable to the desired project id. If you have set this environment variable the code can be even simpler:

      namespace gcs = ::google::cloud::storage;
      using ::google::cloud::StatusOr;
      [](gcs::Client client, std::string const& bucket_name) {
        StatusOr<gcs::BucketMetadata> bucket_metadata =
            client.CreateBucket(bucket_name, gcs::BucketMetadata());
        if (!bucket_metadata) throw std::move(bucket_metadata).status();

        std::cout << "Bucket " << bucket_metadata->name() << " created."
                  << "\nFull Metadata: " << *bucket_metadata << "\n";
      }

###### See Also

[`google::cloud::storage::ProjectIdOption`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/structgoogle_1_1cloud_1_1storage_1_1ProjectIdOption)

## Endpoint Overrides

`CLOUD_STORAGE_EMULATOR_ENDPOINT=...`: override the default endpoint used by the library. Intended for testing only.

`CLOUD_STORAGE_TESTBENCH_ENDPOINT=...`: **DEPRECATED** please use `CLOUD_STORAGE_EMULATOR_ENDPOINT` instead.

###### See Also

[`google::cloud::storage::RestEndpointOption`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/structgoogle_1_1cloud_1_1storage_1_1RestEndpointOption)

###### See Also

[`google::cloud::storage::IamEndpointOption`](https://docs.cloud.google.com/cpp/docs/reference/storage/latest/structgoogle_1_1cloud_1_1storage_1_1IamEndpointOption)

## Enabling Experimental Behaviors

`GOOGLE_CLOUD_CPP_STORAGE_REST_CONFIG=...`: configuration for the REST protocol, but currently unused.

`GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG=...`: this is deprecated.

## Logging

`CLOUD_STORAGE_ENABLE_TRACING=raw-client`: enables logging for each "RPC" generated by the library. Unless you have configured your own logging backend, you should also set `GOOGLE_CLOUD_CPP_ENABLE_CLOG` to produce any output on the program's console.

`CLOUD_STORAGE_ENABLE_TRACING=http`: enables logging for the full http traffic generated by the library.

`CLOUD_STORAGE_ENABLE_TRACING=raw-client,http`: enables all logging.

###### See Also

[`google::cloud::GrpcTracingOptionsOption`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/structgoogle_1_1cloud_1_1GrpcTracingOptionsOption.html)`GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes`: turns on logging in the library, basically the library always "logs" but the logging infrastructure has no backend to actually print anything until the application sets a backend or they set this environment variable.

###### See Also

[`google::cloud::LogBackend`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1LogBackend.html)

###### See Also

[`google::cloud::LogSink`](https://docs.cloud.google.com/cpp/docs/reference/common/latest/classgoogle_1_1cloud_1_1LogSink.html)