本文示例源码:https://github.com/liangshiw/LogDashboard/tree/master/samples/abpvnext
ABP是aspnetcore3.0的开源web应用程序框架,非常适合现代web应用程序。有关ABP的更多内容可以查看官方文档
Logdashboard可以直接在基于abp应用程序中安装使用
本文假设你了解ABP,并不对其做详细解释
使用 abp cli
创建项目
abp new BootStore
使用以下代码覆盖Program
中的Serilog
配置
Log.Logger = new LoggerConfiguration()#if DEBUG.MinimumLevel.Debug()#else.MinimumLevel.Information()#endif.MinimumLevel.Override("Microsoft", LogEventLevel.Information).Enrich.FromLogContext().WriteTo.Async(c => c.File("Logs/logs.log", outputTemplate: "{Timestamp:HH:mm} || {Level} || {SourceContext:l} || {Message} || {Exception} ||end {NewLine}")).CreateLogger();
Install-Package LogDashboard
打开 BootStoreWebModule
类
在ConfigureServices
方法末尾添加以下代码
context.Services.AddLogDashboard(opt => opt.SetRootPath(hostingEnvironment.ContentRootPath));
在OnApplicationInitialization
方法末尾添加以下代码
app.UseLogDashboard();
迁移后运行项目,导航到/logdashboard
enjoy