serilog-aspnetcore icon indicating copy to clipboard operation
serilog-aspnetcore copied to clipboard

Updating Serilog.AspNetCore package to 4.0, application cannot load Serilog.Sinks.Debug

Open mcattle opened this issue 3 years ago • 2 comments

Description When updating the Serilog.AspNetCore Nuget package in a .Net 5.0 Windows Service from 3.4.0 to 4.0.0 and publishing the service in Release mode, the service fails to start because it cannot load Serilog.Sinks.Debug. The service is published with PublishSingleFile=True.

  • Explicitly adding the Serilog.Sinks.Debug 2.0.0 Nuget package to the project and publishing the application did not resolve this issue.
  • Reverting the Serilog.AspNetCore package to 3.4.0 resolved the issue as a temporary workaround, but we like to keep our Nuget packages up to date.

Relevant package, tooling and runtime versions

  • Serilog.AspNetCore 3.4.0, 4.0.0
  • Serilog.Sinks.Debug 2.0.0
  • Windows Server
  • Visual Studio 2019 16.8.6, 16.9.1
  • dotnet 5.0.103

mcattle avatar Mar 09 '21 23:03 mcattle

Thanks for the heads-up, sounds like this will need some investigation.

IIRC there's some conditional compilation around System.Diagnostics.Debug that might be either broken in the 2.0.0 version of Serilog.Sinks.Debug, or, the trimming mechanism in single file publishing may be involved.

I'm flat out for a few days, so if anyone following along has a chance to dig in and investigate that would be very welcome :-)

nblumhardt avatar Mar 09 '21 23:03 nblumhardt

Does Serilog.AspNetCore 3.4.0 together with Serilog.Sinks.Debug 2.0.0 (as opposed to version 1.0.1 of the debug sink that the aspnetcore package uses by default) work?

(I gave it a quick go on an ASP.Net Core project at work and fell over https://github.com/serilog/serilog-settings-configuration/issues/239, which isn't ideal itself!)

Numpsy avatar Mar 10 '21 12:03 Numpsy