manigandham/serilog-sinks-googlecloudlogging

4.0.0 appears broken at GoogleCloudLogging

unaisvayani opened this issue · 3 comments

I have an application on .NET 5 using library Serilog.Sinks.GoogleCloudLogging Version="4.0.0" which is the latest version at this moment.

I have my custom logging library where Serilog is implemented to configure multiple sinks. While the logger object is being configured, I get this run time exception in the code below.

Here is the code where the sink is configured

 logger.WriteTo.GoogleCloudLogging(
      sinkOptions: config.options, 
      outputTemplate: config.OutputTemplate, 
      restrictedToMinimumLevel: config.minLevel);

Exception appears:

SysSystem.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'Void Google.Api.Gax.Grpc.ClientBuilderBase`1..ctor()'.
  Source=Google.Cloud.Logging.V2
  
  StackTrace:
   at Google.Cloud.Logging.V2.LoggingServiceV2ClientBuilder..ctor()
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSink..ctor(GoogleCloudLoggingSinkOptions sinkOptions, ITextFormatter textFormatter)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, GoogleCloudLoggingSinkOptions sinkOptions, Nullable`1 batchSizeLimit, Nullable`1 period, Nullable`1 queueLimit, String outputTemplate, ITextFormatter textFormatter, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch)
   at Serilog.Sinks.GoogleCloudLogging.GoogleCloudLoggingSinkExtensions.GoogleCloudLogging(LoggerSinkConfiguration loggerConfiguration, String projectId, String resourceType, String logName, Dictionary`2 labels, Dictionary`2 resourceLabels, Boolean useSourceContextAsLogName, Boolean useJsonOutput, Boolean useLogCorrelation, String googleCredentialJson, String serviceName, String serviceVersion, Nullable`1 batchSizeLimit, Nullable`1 period, Nullable`1 queueLimit, String outputTemplate, ITextFormatter textFormatter, LogEventLevel restrictedToMinimumLevel, LoggingLevelSwitch levelSwitch)
   at Lib.Logs.Log.CreateLoggerFromConfiguration() in D:\...\lib\Liblog\src\lib.logs\Logger.cs:line 87
   at Lib.Logs.Log.CreateLogger() in D:\...\lib\Liblog\src\lib.logs\Logger.cs:line 82
   at Lib.Logs.Log.Configure() in D:\...\lib\Liblog\src\lib.logs\Logger.cs:line 22
   at ChatBot.Program.Main(String[] args) in D:\...\ChatBot\Program.cs:line 25

Am I missing something to make it work?

Looks like the GCP team just released new libraries with breaking changes for GAX4 with a new underlying GRPC implementation.

https://github.com/googleapis/google-cloud-dotnet/releases/tag/Google.Cloud.Logging.V2-4.0.0

This library references Google.Cloud.Logging.V2 at version 3.6.0:

<PackageReference Include="Google.Cloud.Logging.V2" Version="3.6.0" />

You can set it to that explicitly for now. I'll check on the upgrade issue later.

I referenced version 4.0.0 of Google.Cloud.Logging.V2 and it just worked.
Thanks for the response @manigandham

Version 5.0.0 has been released that uses the new libraries. Support for netstandard2.0 has been dropped.

https://www.nuget.org/packages/Serilog.Sinks.GoogleCloudLogging/5.0.0

https://cloud.google.com/dotnet/docs/reference/help/breaking-gax4