The standard logging abstraction for .NET Core / ASP.NET Core applications is Microsoft.Extensions.Logging. Much like Common.Logging, this is a facade that delegates to whatever logging provider has been configured by the application.
This PR adds an adapter that directs all LaunchDarkly.Logging output to Microsoft.Extensions.Logging. To create this, you call Logs.CoreLogging(loggingFactory)— where loggingFactory is an implementation of Microsoft.Extensions.Logging.ILoggerFactory. A .NET Core application would typically either obtain the ILoggingFactory through dependency injection, or create it programmatically. I don't think there is such a thing as a globalILoggingFactory that we could automagically access, so we do need for them to pass that parameter to us.
Microsoft.Extensions.Logging is not part of the .NET Standard API— it's a package that's distributed with .NET Core. So we don't want to have any dependencies on it from the .NET Standard 2.0 build of LaunchDarkly.Logging; that would cause problems for instance in the Xamarin SDK, which uses .NET Standard dependencies and does not have access to .NET Core. So, I've added a specific .NET Core 2.0 target to this package; the new method is included only in that target, through conditional compilation. Any .NET Core / ASP.NET Core application that references LaunchDarkly.Logging will get the .NET Core 2.0 version, whereas any portable code that is written against .NET Standard will get the .NET Standard 2.0 version that doesn't have this new adapter.
Correction: our lowest compatible .NET Core version is 2.1, not 2.0. .NET Core 2.0 is EOL and won't be supported in any of our upcoming major version releases.
The standard logging abstraction for .NET Core / ASP.NET Core applications is
Microsoft.Extensions.Logging
. Much likeCommon.Logging
, this is a facade that delegates to whatever logging provider has been configured by the application.This PR adds an adapter that directs all
LaunchDarkly.Logging
output toMicrosoft.Extensions.Logging
. To create this, you callLogs.CoreLogging(loggingFactory)
— whereloggingFactory
is an implementation ofMicrosoft.Extensions.Logging.ILoggerFactory
. A .NET Core application would typically either obtain theILoggingFactory
through dependency injection, or create it programmatically. I don't think there is such a thing as a globalILoggingFactory
that we could automagically access, so we do need for them to pass that parameter to us.Microsoft.Extensions.Logging
is not part of the .NET Standard API— it's a package that's distributed with .NET Core. So we don't want to have any dependencies on it from the .NET Standard 2.0 build ofLaunchDarkly.Logging
; that would cause problems for instance in the Xamarin SDK, which uses .NET Standard dependencies and does not have access to .NET Core. So, I've added a specific .NET Core 2.0 target to this package; the new method is included only in that target, through conditional compilation. Any .NET Core / ASP.NET Core application that referencesLaunchDarkly.Logging
will get the .NET Core 2.0 version, whereas any portable code that is written against .NET Standard will get the .NET Standard 2.0 version that doesn't have this new adapter.