title: Logging to Stackdriver from Google Cloud Endpoints in Kubernetes pod
body: <p>I'm having an issue logging to Stackdriver from my golang api. My configuration:</p>
  
  <ul>
  <li>GKE cluster running on three compute engine instances</li>
  <li>Logging and monitoring enabled on GKE container cluster</li>
  <li>Go service behind ESP</li>
  <li>There are three nodes in the kube-system namespace running the <code>fluentd</code> image. Names as fluentd-cloud-logging-xxx-xxx-xxx-default-pool-nnnnnn.</li>
  <li>When I run my service locally (generated using go-swagger) text entries are sent to the <code>global</code> stackdriver log. Nothing when I deploy to my k8s cluster though.</li>
  </ul>
  
  <p>Code I'm using is like: </p>
  
  <pre><code>    api.Logger = func(text string, args ...interface{}) {
      ctx := context.Background()
  
      // Sets your Google Cloud Platform project ID.
      projectID := "my-project-name"
  
      // Creates a client.
      client, err := logging.NewClient(ctx, projectID)
      if err != nil {
          log.Fatalf("Failed to create client: %v", err)
      }
  
      // Sets the name of the log to write to.
      logName := "tried.various.different.names.with.no.luck"
  
      // Selects the log to write to.
      logger := client.Logger(logName)
  
      // Sets the data to log.
      textL := fmt.Sprintf(text, args...)
  
      // Adds an entry to the log buffer.
      logger.Log(logging.Entry{Payload: textL, Severity: logging.Critical})
  
      // Closes the client and flushes the buffer to the Stackdriver Logging
      // service.
      if err := client.Close(); err != nil {
          log.Fatalf("Failed to close client: %v", err)
      }
  
      fmt.Printf("Logged: %v\n", textL)
  
  }
  </code></pre>
  
  <p>I don't need error reporting at the moment as I'm just evaluating - I'd be happy with just sending unstructured text. But it's not clear whether I need to do something like <a href="https://stackoverflow.com/questions/36379572/how-to-setup-error-reporting-in-stackdriver-from-kubernetes-pods/36476771#36476771">Boris' discussion on error reporting/stack traces from Kubernetes pods</a> just to get that?</p>