serilog / serilog-extensions-logging

Serilog provider for Microsoft.Extensions.Logging
Apache License 2.0
307 stars 97 forks source link

SerilogLogger.cs: PrepareWrite Method not found Serilog.Events.LogEvent..ctor #238

Closed davidcaldas closed 5 months ago

davidcaldas commented 5 months ago

Hi!

I have an issue while using the package in a simple console application with .NET Framework 4.7.2. The problem is in the SerilogLogger.cs file in the method PrepareWrite.

When I try logging I get this error:

Failed to write event through SerilogLogger: 
System.MissingMethodException: Method not found: 'Void Serilog.Events.LogEvent..ctor(System.DateTimeOffset, Serilog.Events.LogEventLevel, System.Exception, Serilog.Events.MessageTemplate, System.Collections.Generic.IEnumerable`1<Serilog.Events.LogEventProperty>, System.Diagnostics.ActivityTraceId, System.Diagnostics.ActivitySpanId)'.
   at Serilog.Extensions.Logging.SerilogLogger.PrepareWrite[TState](LogEventLevel level, EventId eventId, TState state, Exception exception, Func`3 formatter).

Unit tests are failing in .NET48 image

nblumhardt commented 5 months ago

Hi @davidcaldas; looks like you have a mix of Serilog versions in there. Adding a direct reference to the Serilog package, v3.1.1, should sort it out.

nblumhardt commented 5 months ago

Ah, or you have an old version of Serilog in your GAC.

davidcaldas commented 5 months ago

Thank @nblumhardt for the help. The version 2.1 of GAC was being loaded instead of the local 3.1..