dotnetcore / AgileConfig

基于.NET Core开发的轻量级分布式配置中心 / .NET Core lightweight configuration server
MIT License
1.5k stars 299 forks source link

.Net 7和8中怎么配置使用 #161

Closed supersdar closed 8 months ago

supersdar commented 8 months ago

var builder = WebApplication.CreateBuilder(args); builder.Configuration.AddAgileConfig(); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.AddAgileConfig(); var app = builder.Build();

// Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles();

app.UseRouting(); app.UseAuthorization();

app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run(); 大佬,加一下新版net core的配置吧.我自己试来试去读不到

kklldog commented 8 months ago

参考 .NET6 https://github.com/kklldog/AgileConfig_Client/blob/50c05bb01663f4652f06b0e73e2d42c5cc67d9f7/AgileConfigMVCSampleNET6/Program.cs#L13

supersdar commented 8 months ago

不是吧。还得安装NLog.Extensions.Logging、using NLog.Web、using Serilog。这也太太太麻烦了。能不能单加一个builder.Host.UseAgileConfig(); 就能自动替换默认的Configuration接口

kklldog commented 8 months ago

不是吧。还得安装NLog.Extensions.Logging、using NLog.Web、using Serilog。这也太太太麻烦了。能不能单加一个builder.Host.UseAgileConfig(); 就能自动替换默认的Configuration接口

。。。。 你在说什么。。 如果你不需要当然不用安装 serilog,我只是顺便演示一下如何使用 serilog 而已。 你只需要调用 UseAgileConfig 方法就可以。

supersdar commented 8 months ago

加了“builder.Host.UseAgileConfig();”,但是获取不到

supersdar commented 8 months ago

@kklldog 找到原因了,是防火墙把端口ban了,像这种情况应该也有会错误日志吧。要去哪里看。等有同样问题时,以后用户也能自己找

kklldog commented 8 months ago

@kklldog 找到原因了,是防火墙把端口ban了,像这种情况应该也有会错误日志吧。要去哪里看。等有同样问题时,以后用户也能自己找

在 client 侧肯定会有日志,类似 server refuse the request 这种