windows-services

Dependency Injection in ASP.NET Core Worker Service

陌路散爱 提交于 2020-12-31 20:00:17
问题 I'm facing some dependency injection issues in .NET Core Worker Service. Please see the below code in Program.cs file. public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsof)t", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.File(@"C:\MyApp_Log\Log.txt") .CreateLogger(); try { Log.Information("Starting up the service."); CreateHostBuilder(args).Build().Run(); return; } catch (Exception ex) { Log.Fatal(ex