From 5110c390d8dde24f3843fd43128640ae0ca6bad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=87=E9=98=B3=20=E9=82=B9?= Date: Tue, 24 Oct 2023 00:38:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A02=E3=80=820=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=9A=84=E9=80=9A=E4=BF=A1=E4=B8=BB=E6=9C=BA=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0http=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 24Hour/Program.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/24Hour/Program.cs b/24Hour/Program.cs index deb7a70..17c60fc 100644 --- a/24Hour/Program.cs +++ b/24Hour/Program.cs @@ -20,6 +20,7 @@ using AutoMapper; using System.Reflection; using Elight.Entity; using _24Hour; +using Microsoft.Extensions.DependencyInjection; #region builder @@ -177,7 +178,10 @@ builder.Services.AddHttpClient(opt => { opt.BaseAddress = new Uri("https://api.weixin.qq.com/sns"); }); - +builder.Services.AddHttpClient(opt => +{ + opt.BaseAddress = new Uri(Configuration.GetSection("CaseTwenty:SysAddress").Value); +}); //builder.Services.AddAuthorization(); builder.Services.AddHttpContextAccessor(); builder.Services.AddScoped(); @@ -195,6 +199,11 @@ builder.Services.AddScoped(sp => }); return db; }); +//添加httpclient 日志记录 +builder.Services.AddHttpLogging(logging => +{ + logging.LoggingFields = Microsoft.AspNetCore.HttpLogging.HttpLoggingFields.All; +}); #region 定时任务 // 配置Quartz.NET调度器 @@ -244,6 +253,9 @@ app.UseWebSockets(new WebSocketOptions app.UseStaticFiles(); //app.UseHttpsRedirection(); //路由 + +//使用httpclient日志记录 必须在UseStaticFiles下面 +app.UseHttpLogging(); app.UseRouting(); app.UseAuthentication(); // 启用身份验证中间件 app.UseAuthorization(); // 启用授权中间件 @@ -257,8 +269,8 @@ app.UseSwagger();// app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "24小时一体机 API V1"); - c.RoutePrefix = string.Empty; - + c.RoutePrefix = string.Empty; + }); #endregion