serilog / serilog-extensions-logging

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

Upgrade Microsoft.Extensions.Logging or use abstraction. #171

Closed niemyjski closed 1 year ago

niemyjski commented 4 years ago

I'm getting a type load exception with 3.0.1 and I have no direct dependencies on Microsoft.Extensions.Logging The only dependency I can see is coming from this library. Currently only .NET Core 3.1 is supported (https://dotnet.microsoft.com/platform/support/policy/dotnet-core) would it be possible to bump deps with a new release?

System.TypeLoadException: Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
  at at Microsoft.Extensions.Logging.Logger.BeginScope[TState](TState state)
  at at Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.BeginScope[TState](TState state)
nblumhardt commented 4 years ago

Hi Blake, thanks for the note, which TFM are you targeting?

Numpsy commented 4 years ago

Same issue as #158?

skomis-mm commented 4 years ago

Yes, the same issue #158 @niemyjski , it means the binary version of Microsoft.Extensions.Logging is different (<3.0.0) from .Abstractions version (3.1.3). Why it happens: Serilog.Extensions.Logging -> Microsoft.Extensions.Logging (2.0.0) -> Microsoft.Extensions.Logging.Abstractions (2.0.0) <LibraryProject> -> Microsoft.Extensions.Logging.Abstractions (3.1.3)

If you not add reference for Microsoft.Extensions.Logging package, the result of nuget dependency resolution will be: Microsoft.Extensions.Logging (2.0.0) Microsoft.Extensions.Logging.Abstractions (3.1.3)

I would suggest in this case if your library targets Abstractions package it is better for long term to target the least version possible unless you need specific API from higher version or have compatibility issues. Or add reference to Microsoft.Extensions.Logging (3.1.3) package to the end project

niemyjski commented 4 years ago

Yep, same issue.

niemyjski commented 3 years ago

Any updates on this?

bodisov commented 3 years ago

Any update on this?

abakumov-v commented 3 years ago

@skomis-mm Hi!

Thanks, your suggestion works fine for me 👍

sungam3r commented 1 year ago

@nblumhardt close?

nblumhardt commented 1 year ago

Thanks @sungam3r 👍 fixed in #223