ABP vNext 使用 logdashboard
本文示例源碼:https://github.com/liangshiw/LogDashboard/tree/master/samples/abpvnext
ABP
ABP是aspnetcore3.0的開源web應用程序框架,非常適合現代web應用程序。有關ABP的更多內容可以查看官方文檔
Logdashboard可以直接在基於abp應用程序中安裝使用,關於Logdashboard的更多內容可以查看ASPNETCore開源日志面板 :LogDashboard
示例
本文假設你了解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();
安裝LogDashboard
Install-Package LogDashboard
打開 BootStoreWebModule 類
在ConfigureServices 方法末尾添加以下代碼
context.Services.AddLogDashboard(opt => opt.SetRootPath(hostingEnvironment.ContentRootPath));
在OnApplicationInitialization 方法末尾添加以下代碼
app.UseLogDashboard();
遷移后運行項目,導航到/logdashboard
enjoy
