We are having a .NET 4.7.2 WebForms project that needs to consume a library. That library is also consumed by another application which is based on the Core platform i.e. .NET 6.0
We want to pass an ILogger instance to the library class from both Framework side and Core side. In the Framework side, we are able to create ILogger instance using the Microsoft.Extensions.Logging package and below code.
var serviceCollection = new ServiceCollection();
serviceCollection.AddLogging();
var serviceProvider = serviceCollection.BuildServiceProvider();
ILogger logger = serviceProvider.GetService<ILogger>();
But how do we pass the App Insights and Event Viewer providers to this logger from .NET Framework WebForms?