|
|
|
@ -37,12 +37,16 @@ namespace SlnMesnac.Serilog
|
|
|
|
|
{
|
|
|
|
|
public static IApplicationBuilder UseSerilogExtensions(this IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
// 获取当前程序所在的目录
|
|
|
|
|
string currentDirectory = Directory.GetCurrentDirectory();
|
|
|
|
|
|
|
|
|
|
//启用Serilog中间件
|
|
|
|
|
app.UseSerilogRequestLogging();
|
|
|
|
|
|
|
|
|
|
#region 通过配置文件读取日志存放位置
|
|
|
|
|
var appConfig = app.ApplicationServices.GetService<AppConfig>();
|
|
|
|
|
var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
|
|
|
|
|
// var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
|
|
|
|
|
var logPath = $"{currentDirectory}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console()
|
|
|
|
|