1.效果图片
2.使用abp cli新建一个abp 项目,具体过程可参考abp官网
2.1 打开主项目 Program,并且使用以下代码覆盖Program
中的Serilog
配置
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
2.2 安装LogDashboard
2.3 打开主项目下的打开 xxxWebModule
类
- 在
ConfigureServices
方法末尾添加以下代码
context.Services.AddLogDashboard(opt => opt.SetRootPath(hostingEnvironment.ContentRootPath));
- 在OnApplicationInitialization 方法末尾添加以下代码
app.UseLogDashboard();
2.4 迁移后运行项目,导航到/logdashboard,便可以看到日志面板
参考文章:https://developer.aliyun.com/article/989505
下节介绍如何写日志并用日志面板查看!