在appsettings.json中添加apollo地址
"apollo": {
"AppId": "",
"MetaServer": "http://部署apollo地址"
},
在Program.cs
public static void Main(string[] args)
{
CreateHostBuilder(args).Run();
}
public static IWebHost CreateHostBuilder(string[] args) =>
Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, builder) =>
{
builder
.AddApollo(builder.Build().GetSection("apollo"))
.AddDefault()
.AddNamespace("application");
})
ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddLog4Net();//需要配置文件
})
.UseStartup<Startup>()
.Build();