Skip to content

Remove unnecessary dependencies #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

sungam3r
Copy link
Contributor

@sungam3r sungam3r commented Sep 2, 2019

image
I think that these dependencies were added unintentionally due to sample projects that reference the main package.

In fact, only two are enough:
image

@nblumhardt
Copy link
Member

Thanks Ivan! This is #110 - moving this package towards a "batteries included" approach, since the core UseSerilog() functionality is now implemented in the (low dependency) Serilog.Extensions.Hosting package.

It would be interesting to know which features of Serilog.AspNetCore you're using, so that we can evaluate whether this is the optimal factoring. Cheers!

@sungam3r
Copy link
Contributor Author

sungam3r commented Sep 3, 2019

Wow! I could not even imagine that it was intended. I highly recommend not including such dependencies. It's like shooting yourself in the foot. With the same success, you can turn on a bunch of other sinks/formatters/appconfigs/etc. in the hope that they will be useful to someone. But in fact, only version conflicts will arise when the consumer uses a package of another major version. These are all spurious dependencies.

The goal is to make the onboarding process smoother.

In this case, you can make a separate package and name it like Serilog.AspNetCore.All but I still would not recommend doing so.

For some consumers, this concern actually turns into problems of versioning dependencies. And the other part simply does not use this "ballast". You have already done sample projects with good examples. No need to mix.

@sungam3r
Copy link
Contributor Author

sungam3r commented Sep 3, 2019

It would be interesting to know which features of Serilog.AspNetCore you're using, so that we can evaluate whether this is the optimal factoring.

I use Serilog.Sinks.Kafka for example.

@nblumhardt
Copy link
Member

Thanks for the reply!

As you'd know, the Serilog packages are all very fine-grained, for many of the reasons you point out. Unfortunately, something resembling a meta-package is needed if we're going to meet the ease-of-setup expectations set by Microsoft.Extensions.Logging/ASP.NET Core, which includes console and debug logging by default.

I use Serilog.Sinks.Kafka for example.

Sorry, I meant which features from this package? Since the core logging adapters and UseSerilog() are now in Serilog.Extensions.Logging and Serilog.Extensions.Hosting, the only feature actually implemented directly in this package is UseSerilogRequestLogging() - unless you're using that middleware, then Serilog.Extensions.Hosting is possibly the dependency-free package that you're looking for. Let me know! 👍

None of this set in stone, of course! It will be interesting to see whether the batteries-included approach here reduces some of the support around this package, or ends up increasing it. We can definitely re-evaluate and change direction if needed.

<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should in any case be able to get rid of these two 👍

@@ -205,7 +205,7 @@ Finally, pass the provider collection into `UseSerilog()`:

Providers registered in _Startup.cs_ with `AddLogging()` will then receive events from Serilog.

**Using iniline initialization:**
**Using inline initialization:**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, nice catch 😅

@sungam3r
Copy link
Contributor Author

sungam3r commented Sep 3, 2019

unless you're using that middleware, then Serilog.Extensions.Hosting is possibly the dependency-free package that you're looking for

When I read this comment, I realized that this is what I needed. But when I opened the source code, I was disappointed. It uses IHostBuilder, but I need IWebHostBuilder. So Serilog.Extensions.Hosting package only integrates logging to Generic Host and the package name can be misleading.

Relates to #126

@nblumhardt
Copy link
Member

Ah, thanks for the follow-up. This is a point-in-time issue, I think, since in .NET Core 3.0, startup will be HostBuider-based (with WebHostBuilder deprecated), so generally the IHostBuilder will be the desirable place to configure logging - unless I've misunderstood how these are intended to evolve - does that match your understanding?

@sungam3r
Copy link
Contributor Author

sungam3r commented Sep 4, 2019

Yes, but it will be only in netcoreapp3.0 and netstandard2.1. Still need to wait for the release. For netstandard2.0 there is no such unification.

@nblumhardt
Copy link
Member

Thanks for the reply. It sounds like there's a bit of a compromise necessary for the time being on netcoreapp2.x 🤔

@nblumhardt
Copy link
Member

3.0 is now available, I think that's the way forwards. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants