Google Cloud Certified Associate Cloud Engineer Practice

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for the Google Cloud Certified Associate Cloud Engineer Exam with flashcards and multiple choice questions. Each question includes hints and explanations to help you study effectively. Get ready to pass your certification exam!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What method is recommended to write to Stackdriver logs from a Cloud Function?

  1. Use Stackdriver SDK

  2. Invoke Stackdriver API

  3. Use the logging package or write to standard out

  4. Redirect output to Stackdriver

The correct answer is: Use the logging package or write to standard out

Using the logging package or writing to standard output is recommended when writing to Stackdriver (now known as Google Cloud Logging) from a Google Cloud Function. This approach takes advantage of the built-in integration that Cloud Functions have with Cloud Logging. By using the logging methods available in the Node.js or Python runtime, for example, logs can be easily structured, and certain contextual information can be captured without the need for additional libraries or SDKs. When you write to standard output (stdout) within a Cloud Function, the platform automatically captures and routes these logs to Cloud Logging. This is efficient and convenient, as it eliminates the need to make explicit API calls or manage SDK dependencies, allowing developers to focus on the functionality of their function rather than log management. In contrast, other methods like invoking Stackdriver APIs or using a specific SDK introduce extra complexity and are generally unnecessary for this scenario where automatic logging integration is available. Redirecting output to Stackdriver is also not a direct or practical method, as goal-oriented developers typically rely on structured logging through supported packages or standard output. This integration simplifies monitoring and managing logs, making the recommended method more suitable for developers working within the Google Cloud ecosystem.