serilog-extensions-logging icon indicating copy to clipboard operation
serilog-extensions-logging copied to clipboard

Switch to Microsoft.Extensions.Logging.Abstractions

Open Cheesebaron opened this issue 4 years ago • 7 comments
trafficstars

This PR adresses the following:

  • Manage packages centrally instead of package version scattered all over the projects
  • Switch to Microsoft.Extensions.Logging.Abstractions + Serilog as the only dependencies for the library
  • Don't abuse the transitive dependency Microsoft.Extensions.Logging pulls in, such as Microsoft.Extensions.DependencyInjection to add DependencyInjection helpers, it should be more explicit then
  • Switch test projects to a modern net5.0 tfm
  • Update all dependencies to latest stable
  • Adds sourcelink support to the NuGet packages

Cheesebaron avatar Jun 17 '21 16:06 Cheesebaron

Thanks for the PR! This seems like it would cause significant pain downstream - many consumers of this package use loggingBuilder.AddSerilog() - any thoughts on how that should be handled?

nblumhardt avatar Jun 18 '21 01:06 nblumhardt

Yeah, maybe it should be added back, but by adding a explicit dependency on Microsoft.Extensions.DependencyInjection.

Alternatively, that should live in a different assembly, but that is not nice either.

EDIT:

Actually, ILoggingBuilder is only present in Microsoft.Extensions.Logging and not the abstractions. Would it be a huge issue if the dependency injection stuff lived in its own assembly?

The same goes for the ProviderFilter attribute I removed.

EDIT 2:

I've just pushed a new commit where I added a separate library for the extension. Let me know if this is the route you want to go.

Cheesebaron avatar Jun 18 '21 07:06 Cheesebaron

I don't know if it is related but we're about to completely dump Serilog over a MethodNotFound exception that seems to plague projects using the Microsoft Logging Abtractions. https://github.com/PowerShell/PowerShellEditorServices/issues/1477

I happened across this pull request and perhaps it would solve our issues.

I haven't 100% nailed it down, but it appears that when a calling process is running .Net 5, AddSerilog() is simply not available.

The odd part is when I add the full csproj to my solution and mark it as a project dependency it is magically resolvable.

PowerShellEditorServices isn't directly importing this extension, but it calls OmniSharp which appears to be using it.

Thoughts?

dkattan avatar Jun 22 '21 00:06 dkattan

@dkattan thanks for the ping. I think the tracking issue on the Serilog side is https://github.com/serilog/serilog-sinks-file/issues/135 - will centralize discussion there.

nblumhardt avatar Jun 22 '21 00:06 nblumhardt

@dkattan you could as an experiment try grabbing the artifacts on the AppVeyor build here: https://ci.appveyor.com/project/serilog/serilog-framework-logging/builds/39654298 and see how that works out for you.

Cheesebaron avatar Jun 22 '21 10:06 Cheesebaron

@nblumhardt I've started implementing Serilog using the Microsoft.Extensions.Logging package as well. We've got .NET 6 and Framework 4.7.1 projects that we're straddling, but want to introduce the common interfaces from Microsoft.

I've had to manually pick Microsoft.Extensions.Logging version 2.0.0 (deprecated) instead of 2.2.0. I can open a new issue/PR if need be, but thought this issue related: can we at the very least version bump to 2.2.0 ?

stphnlwlsh avatar Jul 07 '22 19:07 stphnlwlsh

@stphnlwlsh a separate PR that addresses the dependency version only would be welcome - this PR is unlikely to move forward at this point due to the potential for breaking changes downstream. Thanks for the note!

nblumhardt avatar Jul 15 '22 22:07 nblumhardt

@stphnlwlsh a separate PR that addresses the dependency version only would be welcome - this PR is unlikely to move forward at this point due to the potential for breaking changes downstream. Thanks for the note!

@nblumhardt I suggest to close this abandoned PR since it mixes changes in CI with actual code changes. #214 upgrades the code base and CI without any actual code changes.

sungam3r avatar Mar 06 '23 16:03 sungam3r

Of course switching to Microsoft.Extensions.Logging.Abstractions can be tracked by another issue if someone needs it.

sungam3r avatar Mar 06 '23 16:03 sungam3r