I am creating an application framework that can be shared between .Net Core 1.2, .Net Core 2.0 and .NET Framework 4.6+. So I choose the target framework of my project as .NE
Yes it can. If you have to support netcore 1, then
Install-Package Microsoft.Extensions.Logging -Version 1.1.2
would work:
But better still your reusable component only need rely on the Abstractions
:
Install-Package Microsoft.Extensions.Logging.Abstractions -Version 1.1.2
Your component only need reference ILogger
, and the applications that use your component are not tied to using the MS extensions logger. In particular, if you look at the dependencies for
Serilog.Extensions.Logging -Version 2.0.2
At https://www.nuget.org/packages/Serilog.Extensions.Logging/ , you can see that it depends on Abstractions
but doesn't depend on the MS Extensions logger.
Serilog does depend on netstandard1.3. But again the netstandard version page tells you all your targets support it.
The applications using your framework can then carry on using Serilog, so long as they know how to wrap a serilogger as a MS.Extensions ILogger. the SerilogLoggerProvider
in Serilog.Extensions.Logging does the trick:
var msFrameworkLogger= new SerilogLoggerProvider(myExistingSerilog).CreateLogger("name");