I've built a docker image for GKE, and want to use Google Stackdriver Logging.
For the moment I'm just trying to log Service started
when a service starts.
While running the container on my host works well (In Google Cloud Console
> Logs Viewer
> Global
, I can see Service started
when expected), running the container the exact same way on Google Cloud Shell doesn't log anything. Deploying to GKE does the exact same behavior, no errors but I can't find the supposedly created logs.
Here are the scopes for my cluster:
cloud-platform,compute-rw,datastore,default,storage-full,logging-write,service-control,service-management
.
Note that the logging client gets successfully created:
client, err := logging.NewClient(ctx, projectID)
if err != nil {
log.Fatalf("Failed to create the logging client: %v", err)
} else {
fmt.Println("Logging client created")
}
app.Logger = client.Logger(logName)
text := "Started service !"
app.Logger.Log(logging.Entry{
Payload: text,
})
I get "Logging client created" every time in my cluster logs, or when running the container manually inside the Google Cloud Shell. But I get "Started service !" only when running the container on my own machine.