asp爆网站绝对路径,南宁专业网站制作公司,深圳创业补贴2024,怎么申请域名和备案文章目录 项目地址一、Serilog使用1.1 安装 Serilog1.2 注册日志服务1.3 设置日志级别和详情1.4 配置到文件里1.5 给不同的环境配置日志1.5.1 配置appsettings.Development.json二、Swagger的使用三、自定义Exception中间件3.1 使用FluentValidation项目地址 教程作者:教程地址… 文章目录 项目地址一、Serilog使用1.1 安装 Serilog1.2 注册日志服务1.3 设置日志级别和详情1.4 配置到文件里1.5 给不同的环境配置日志1.5.1 配置appsettings.Development.json 二、Swagger的使用三、自定义Exception中间件3.1 使用FluentValidation 项目地址
教程作者:教程地址:代码仓库地址:所用到的框架和插件:dbt
airflow一、Serilog使用
1.1 安装 Serilog
给Restaurants.API层安装Serilog ItemGroupPackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0"PrivateAssetsall/PrivateAssetsIncludeAssetsruntime; build; native; contentfiles; analyzers; buildtransitive/IncludeAssets/PackageReferencePackageReference Include="Serilog.AspNetCore" Version="9.0.0" //ItemGroup1.2 注册日志服务
注册日志服务到程序入口Program.cs
builder.Host.UseSerilog((context, configuration) =configuration.MinimumLevel.Override("Microsoft", LogEventLevel.Warning).MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Information).WriteTo.Console()
);app.UseSerilogRequestLogging();
1.3 设置日志级别和详情
程序入口设置日志级别 ①程序级别是Warning;②EntityFrameworkCore显示Information;③ 配置日志显示内容builder.Host.UseSerilog((context,configuration) =configuration.MinimumLevel.Override("Microsoft",LogEventLevel.Warning).MinimumLevel.Override("Microsoft.EntityFrameworkCore",LogEventLevel.Information).WriteTo.Console(outputTemplate: "[{Timestamp:dd-MM HH:mm:ss} {Level:u3}] |{SourceContext}| {NewLine}{Message:lj}{NewLine}{Exception}")
);在EFcore的配置文件设置日志显示Restaurants.Infrastructure/Extensions/ServiceCollectionExtensions.cs3. 将需要显示的信息添加到各个Handler里
logger