.net core DI注入
最初使用serilog组件,做日志记录工具,有了以下插件代码: public static class ServiceHostBuilderExtensions { public static IServiceCollection UseSeriLog(this IServiceCollection collection, Serilog.ILogger logger = null, bool dispose = false, LoggerProviderCollection providers = null) { if (providers != null) { collection.AddSingleton<ILoggerFactory>(services => { var factory = new SerilogLoggerFactory(logger, dispose, providers); foreach (var provider in services.GetServices<ILoggerProvider>()) factory.AddProvider(provider); return factory; }); } else { collection.AddSingleton<ILoggerFactory>(services => new