redboxllc / stackdriver-serilog

A Stackdriver JSON Formatter for logging with Serilog and .NET
Apache License 2.0
13 stars 6 forks source link

Broken with Serilog v3 #14

Open lol768 opened 1 year ago

lol768 commented 1 year ago

System.MissingMethodException: Method not found: 'Void Serilog.Parsing.TextToken..ctor(System.String, Int32)'.

Culprit: this change

abelbraaksma commented 3 months ago

Just confirming that in my project, after moving to .NET 8.0 and upgrading Serilog, I'm seeing the same issue using Redbox.Serilog.Stackdriver.

webhost-1  | 2024-08-11T17:11:55.0023162Z Caught exception while emitting to sink Serilog.Sinks.SystemConsole.ConsoleSink: System.MissingMethodException: Method not found: 'Void Serilog.Parsing.TextToken..ctor(System.String, Int32)'.
webhost-1  |    at Redbox.Serilog.Stackdriver.StackdriverJsonFormatter.FormatEvent(LogEvent logEvent, TextWriter originalOutput, JsonValueFormatter valueFormatter)
webhost-1  |    at Redbox.Serilog.Stackdriver.StackdriverJsonFormatter.Format(LogEvent logEvent, TextWriter output)
webhost-1  |    at Serilog.Sinks.SystemConsole.ConsoleSink.Emit(LogEvent logEvent)
webhost-1  |    at Serilog.Core.Sinks.SafeAggregateSink.Emit(LogEvent logEvent)

I'm unsure what dependency of all the Serilog dlls this comes from (I first thought Serilog.Sinks.Console). I've updated everything to the latest stable (v4.x Serilog), but this is clearly still happening in Serilog v4.0....

Basically: console logging cannot be used with Serilog anymore since version 3? Anybody aware of a workaround?

lol768 commented 3 months ago

@abelbraaksma

This fork may work for you: https://www.nuget.org/packages/Raileasy.Serilog.Stackdriver

https://github.com/raileasyuk/stackdriver-serilog/commits/master/

abelbraaksma commented 3 months ago

Oh, awesome!!! I'm gonna give it a try 🙏

abelbraaksma commented 3 months ago

@lol768, unfortunately, it didn't work. The same error is still there. I tried downgrading the Serilog assembly, but that had no effect either.

abelbraaksma commented 3 months ago

wait. It still shows Redbox.Serilog.Stackdriver (as opposed to Raileasy.Serilog.Stackdriver in the stacktrace). I think I have a cached dependency or something. The transient dependency was not resolved properly. Weird. Ok, continuing research.... lol

lol768 commented 3 months ago

I was gonna say: that is odd, we're using Serilog (albeit 3.1.1) and that particular package (v1.2.2) with .NET 8 in production today. Package shenanigans might explain it, but do shout if you continue to have issues

abelbraaksma commented 3 months ago

Yeah, my bad. I used docker-compose up and forgot to do a rebuild with docker-compose build --no-cache.

The same issue did not occur when running directly, hence the caching issue. It works!!!! 🪂