fix-日志按天分割存储

dev
liuwf 3 weeks ago
parent 0ed25ea4df
commit c7c6c10937

@ -44,15 +44,15 @@ namespace SlnMesnac.Serilog
app.UseSerilogRequestLogging();
#region 通过配置文件读取日志存放位置
var appConfig = app.ApplicationServices.GetService<AppConfig>();
// var appConfig = app.ApplicationServices.GetService<AppConfig>();
// 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()
.WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information)
.WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error)
.WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning)
.WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information, rollingInterval: RollingInterval.Day)
.WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error, rollingInterval: RollingInterval.Day)
.WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning, rollingInterval: RollingInterval.Day)
//.WriteTo.File(Path.Combine(logPath, "Debug.log"), LogEventLevel.Debug, fileSizeLimitBytes: 5 * 1024)
.CreateLogger();
app.UseSerilogRequestLogging();

Loading…
Cancel
Save