manigandham / serilog-sinks-googlecloudlogging

Serilog sink that writes events to Google Cloud Logging
MIT License
41 stars 25 forks source link

No more Log Entry visible #65

Closed fgaravaglia closed 1 year ago

fgaravaglia commented 1 year ago

From application deployed last time on Middle December, no log entry has been found now, no error founds in CLoud Logging

the configuration has not been changed so far:


  "Serilog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Error",
        "Microsoft.Hosting.Lifetime": "Information",
        "Microsoft.AspNetCore": "Warning",
        "Microsoft.AspNetCore.Hosting.Internal.WebHost": "Warning",
        "Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware": "Warning",
        "Microsoft.AspNetCore.Hosting.Diagnostics": "Warning"
      },
      "Using": [
        "Serilog.Sinks.GoogleCloudLogging",
        "Serilog.Enrichers.ClientInfo",
        "Serilog.Context.LogContext"
      ]
    },
    "Enrich": [
      "FromLogContext",
      "WithClientIp",
      "WithThreadId",
      "WithThreadName",
      "WithEnvironmentUserName",
      "WithMachineName"
    ],
    "WriteTo": [
      {
        "Name": "GoogleCloudLogging",
        "Args": {
          "projectID": "XXXXXXXXX",
          "restricedToMinimumLevel": "Information",
          "labels": {
            "env": "prod",
            "resource": "YYYYYYY"
          }
        }
      }
    ]
  },
manigandham commented 1 year ago

Try using the Serilog SelfLog output to see if there are any exceptions being thrown:

https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics

fgaravaglia commented 1 year ago

I tried to enable selfLog. This is the issue I found int cloud Logging:

`

[SERILOG-SELFLOG] 2023-01-30T22:06:39.6647916Z Exception while emitting periodic batch from Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink: Grpc.Core.RpcException: Status(StatusCode="PermissionDenied", Detail="Permission 'logging.logEntries.create' denied on resource (or it may not exist).") at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass0_0`2.<b__0>d.MoveNext() --- End of stack trace from previous location --- at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()

`

manigandham commented 1 year ago

That error is telling you the problem: "Permission 'logging.logEntries.create' denied on resource (or it may not exist)."

Please read the authentication section of the readme: https://github.com/manigandham/serilog-sinks-googlecloudlogging#authentication

You need to use the correct service account and make sure it has permissions to write logs. Add the Logs Writer role to your service account being used by the application.

fgaravaglia commented 1 year ago

the strange thing is tath it is working without changing anything. I assigned now the role to Cloud Run service Account and it works as expected. Thanks for your support