控制台中的错误是: ConfigureServices返回System.IServiceProvider。
迁移之前(Asp.net Core 2.2)
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureLogging(options => options.ClearProviders())
.UseNLog()
.UseStartup<Startup>();
迁移后(Asp.net Core 3.0)
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions =>
{
// Set properties and call methods on options
})
.UseNLog()
.UseStartup<Startup>();
});
public static void Main(string[] args)
{
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
try
{
logger.Debug("init main");
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
logger.Error(ex, "Stopped program because of exception");
throw;
}
finally
{
segmentation fault on Linux)
NLog.LogManager.Shutdown();
}
}