serilog / serilog-extensions-logging

Serilog provider for Microsoft.Extensions.Logging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade Microsoft.Extensions.Logging or use abstraction.

niemyjski opened this issue · comments

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)

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

Same issue as #158?

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

Yep, same issue.

Any updates on this?

Any update on this?

@skomis-mm Hi!

Thanks, your suggestion works fine for me 👍

Thanks @sungam3r 👍 fixed in #223