Access the open source log panel LogDashboard in the Abp project (1)

1. Effect picture

2. Use the abp cli to create a new abp project, the specific process can refer to the abp official website

2.1 Open the main project Program and use the following code to override the configuration Program inSerilog

 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 Install LogDashboard 

WebModule 2.3 Open the open xxx class  under the main project

  • ConfigureServices Add the following code at the end of the method

 context.Services.AddLogDashboard(opt => opt.SetRootPath(hostingEnvironment.ContentRootPath));
  • Add the following code at the end of the OnApplicationInitialization method

app.UseLogDashboard();

2.4 Run the project after migration, navigate to /logdashboard, you can see the log panel

 

Reference article: https://developer.aliyun.com/article/989505

 The next section describes how to write logs and view them with the log panel!

Guess you like

Origin blog.csdn.net/weixin_39237340/article/details/127063349