serilog-sinks-console
serilog-sinks-console copied to clipboard
Dependencies issues
Dear,
i have a problem with dependecies on Serilog. Basically i use both Serilog 4.2.0.0 and Serilog.Sinks.Console 6.0.0.0 which are both latest versions.
Now, the problem is that Serilog.Sinks.Console has as dependency the Serilog 4.0.0.0 and the issue is that when i deploy my app, it will complain that it needs the version 4.0.0.0 of Serilog.
Could you upgrade the reference?
thank you
Hi! These packages are fully-compatible, the problem here will be either your tooling or CSPROJ setup. Check out discussions/docs online for generation of assembly binding redirects, the build should do this automatically but sometimes things go haywire. HTH!
Hi,
Yes, i'm aware of the binding redirects but some aspect can be considered in my case. 1st, the .net exe loading the dll(which is what i developed and uses serilog) is not mine but 3rd party so i cannot compile it. Second if i play with binding redirect and suppose i fix it(in the past i tried and it did not worked), installing upgrades will automatically break it because it will overwrite the .exe.config file. So everytime there are updates, i need to take care of this aspect. I think i will remove the console at all or find another approach.
Why not at least align the projects of serilog. I mean, the latest version of a sink, must use the latest version of serilog?
What's interesting about this issue is that tools like Polyglot notebook are not able to load and reference items from Serilog.Sinks.Console if you have the latest Serilog and something like Serilog.Sinks.File. Latest Serilog.Sinks.File references 4.2.0. It generates a CS1701 [0] and the cell trying to reference WriteTo.Console() doesn't compile, complaining about the function not being found. As far as I know, there's no way to define a binding redirect for Polyglot notebook, so it ends up requiring me to downgrade both Serilog and Serilog.Sinks.File to older versions in order to align with what Serilog.Sinks.Console needs. Kind of an interesting and annoying one.
[0] https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1701
Thanks for the note @dinomight. What does the "Quick Fix" contextual action suggested by Code do, there? I'd expect Polyglot will have some means of supplying binding redirects, the whole .NET ecosystem relies on them so it'd be a painful missing feature otherwise 🤔
"Quick Fix..." just brings up options around Copilot. Asking copilot isn't particularly helpful as it basically suggests using version specific nuget references. Interestingly, Serilog got a new release to 4.3 since I last posted here and now I get more errors for both the file and sinks projects. I'm tempted to assume that the idea would be for users to just use explicit version dependencies to avoid the binding redirect requirement, but that's certainly an annoying amount of work.
Thanks for the follow-up @dinomight. I think this illustrates the problem; it's not practical to update every package across the whole ecosystem whenever a new version of a dependency is released. If Serilog implemented this in our in-org repos, that's still only a handful of packages, and you'd need to get similar updates from every sink or extension shipped by a different organization.
Binding redirects are the baked-in solution to this; they're generated automatically at build time, and for the most part everything just works without any interaction. It sounds like Polyglot would benefit from a matching feature. Perhaps raising an issue/discussion on that project would be the best next-step?
Cheers, Nick
For future reference, I finally opened a bug in dotnet interactive regarding this: https://github.com/dotnet/interactive/issues/4003
Great - subscribed over there in case I'm able to help at any point. Closing this as it's not a Serilog-specific issue. Cheers!