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

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


@LoekD's answer is absolutely correct. Here's a .NET Framework example of how to use the Microsoft Extentions Logging framework with Serilog.

public class Program{    private static void Main()    {        // instantiate and configure logging. Using serilog here, to log to console and a text-file.        var loggerFactory = new Microsoft.Extensions.Logging.LoggerFactory();        var loggerConfig = new LoggerConfiguration()            .WriteTo.Console()            .WriteTo.File("logs\\myapp.txt", rollingInterval: RollingInterval.Day)            .CreateLogger();        loggerFactory.AddSerilog(loggerConfig);        // create logger and put it to work.        var logProvider = loggerFactory.CreateLogger<Program>();        logProvider.LogDebug("debiggung");    }}

Requires Microsoft.Extensions.Logging, Serilog.Extensions.Logging and Serilog.Sinks.File NuGet packages.


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.