Logging using Google.Cloud.Diagnostics.V2 does not work from Google Cloud GKE
type: questionpriority: p2needs more info
Logging via Logger does work from local machine but does not work when deployed to GKE.
With the following console app, when run on local machine, the logs show in the GCP Logs explorer, but when run on GKE, no logs are stored (except the `Console.WriteLine`).
```CSharp
using Google.Cloud.Diagnostics.Common;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
internal sealed class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Start"); // This gets logged on GKE
var builder = Host.CreateApplicationBuilder(args);
builder.Logging.ClearProviders();
builder.Services.AddGoogleDiagnostics(
projectId: "egate-digi-development",
serviceName: "myService",
serviceVersion: "version"
);
var app = builder.Build();
var logger = app.Services.GetService<ILogger<Program>>();
logger.LogInformation("TEST of Logging with {Params}", "param"); // This is not logged on GKE
await app.RunAsync();
}
}
```
#### Environment details
- OS: Windows (local) / Ubuntu (.NET docker container on GCP GKE)
- .NET version: 10
- Package name and version: Google.Cloud.Diagnostics.Common 5.3.0
- GKE Cluster is created as auto-cluster on GCP, application is under namespace and namespace's default GKE service is used.
- Google Cloud SDK 554.0.0 is installed on local machine with application-default credentials setup.
Note no exception is thrown, even when logging options with `ExceptionHandling.Propagate` were used.
关闭于 2026-04-21 2 条评论