|
|
|
@ -1,16 +1,13 @@
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.HttpsPolicy;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
using Serilog;
|
|
|
|
|
using Serilog.Events;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace Durkee.Mes.Api
|
|
|
|
|
{
|
|
|
|
@ -53,6 +50,20 @@ namespace Durkee.Mes.Api
|
|
|
|
|
//c.DisplayRequestDuration(); // 显示请求持续时间(可选)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.UseSerilogRequestLogging();
|
|
|
|
|
//Log.Logger = new LoggerConfiguration()
|
|
|
|
|
// .MinimumLevel.Information().WriteTo.Console()
|
|
|
|
|
// .WriteTo.File($"Logs/{DateTime.UtcNow:yyyyMMdd}/.txt", rollingInterval: RollingInterval.Day)
|
|
|
|
|
// .CreateLogger();
|
|
|
|
|
var logPath = $"E:/代码生成/日志信息/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
|
|
|
|
|
Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.Console()
|
|
|
|
|
.WriteTo.File(Path.Combine(logPath, "Info.log"), LogEventLevel.Information, fileSizeLimitBytes: 5*1024)
|
|
|
|
|
.WriteTo.File(Path.Combine(logPath, "Error.log"), LogEventLevel.Error, fileSizeLimitBytes: 5 * 1024)
|
|
|
|
|
.WriteTo.File(Path.Combine(logPath, "Warn.log"), LogEventLevel.Warning, fileSizeLimitBytes: 5 * 1024)
|
|
|
|
|
.WriteTo.File(Path.Combine(logPath, "Trace.log"), LogEventLevel.Verbose, fileSizeLimitBytes: 5 * 1024)
|
|
|
|
|
.CreateLogger();
|
|
|
|
|
app.UseSerilogRequestLogging();
|
|
|
|
|
|
|
|
|
|
//app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
@ -63,6 +74,8 @@ namespace Durkee.Mes.Api
|
|
|
|
|
{
|
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Log.Information($"项目初始化完成,日志存放路径:{logPath}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|