Google Cloud Professional Cloud Developer — Question 229
You have an application running on Google Kubernetes Engine (GKE). The application is currently using a logging library and is outputting to standard output. You need to export the logs to Cloud Logging, and you need the logs to include metadata about each request. You want to use the simplest method to accomplish this. What should you do?
Answer options
- A. Change your application’s logging library to the Cloud Logging library, and configure your application to export logs to Cloud Logging.
- B. Update your application to output logs in JSON format, and add the necessary metadata to the JSON.
- C. Update your application to output logs in CSV format, and add the necessary metadata to the CSV.
- D. Install the Fluent Bit agent on each of your GKE nodes, and have the agent export all logs from /var/log.
Correct answer: A
Explanation
The correct answer is A because using the Cloud Logging library is the simplest way to ensure that logs are formatted correctly and include metadata for each request automatically. Options B and C require additional formatting and manual metadata handling, which complicates the process. Option D involves deploying and managing an additional service, which is not as straightforward as directly integrating the Cloud Logging library.