asp.net.netazureloggingazure-diagnostics

How does Microsoft.Extensions.Logging work for full .net framework?


The article (Monitor and diagnose Azure Service Fabric applications) indicates following (please note text in bold):

ASP.NET Core logging

Choosing how to instrument your code can be difficult, if you chose poorly and have to reinstrument, you are revisiting and potentially destabilizing your code base. To reduce the risk, developers can choose an instrumentation library such as Microsoft.Extensions.Logging provided by ASP.NET Core. This provides an ILogger interface that allows the provider of your choice to be used while minimizing the impact to existing code. Another nice aspect of this is that the code can be used not only in .NET Core on Windows and Linux, but in the full .NET framework too, giving the ability to standardize your instrumentation code across .NET and .NET Core.

How is this supposed to work because when I tried to add the extensions library (to my service fabric cluster application project that compiles to .NET framework 4.5.2), it is attempting to bring down all ASP.NET Core related binaries?


Solution

  • This means that the library 'Microsoft.Extensions.Logging' is compiled against netstandard (1.1), which means it can be used by both full framework (4.5+) applications and dotnet core applications.

    Adding the net standard metapackage introduces a bunch of dependencies, but since your project is targeting the full framework, they won't actually be used by your service.