修改日志
parent
3f8b709446
commit
6c8244d36c
|
@ -50,6 +50,10 @@
|
||||||
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.1" />
|
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.2.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.3" />
|
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.3" />
|
||||||
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="5.1.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="5.1.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.5.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.5.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.5.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.5.1" />
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using NLog.Web;
|
using NLog.Web;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace IRaCIS.Core.API
|
namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
|
@ -12,24 +13,11 @@ namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
ImageManager.SetImplementation(WinFormsImageManager.Instance);
|
ImageManager.SetImplementation(WinFormsImageManager.Instance);
|
||||||
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger.Debug("init main");
|
|
||||||
CreateHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
//NLog: catch setup errors
|
|
||||||
logger.Error(exception, "Stopped program because of exception");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
||||||
NLog.LogManager.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
|
@ -38,20 +26,19 @@ namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
webBuilder.ConfigureKestrel((context, options) =>
|
webBuilder.ConfigureKestrel((context, options) =>
|
||||||
{
|
{
|
||||||
//设置应用服务器Kestrel请求体最大为1GB // if don't set default value is: 30 MB
|
//设置应用服务器Kestrel请求体最大为1GB // if don't set default value is: 30 MB
|
||||||
options.Limits.MaxRequestBodySize = long.MaxValue;
|
options.Limits.MaxRequestBodySize = long.MaxValue;
|
||||||
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(30);
|
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(30);
|
||||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(30);
|
options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(30);
|
||||||
});
|
});
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>();
|
||||||
})//使用Autofac替代本身容器
|
})//使用Autofac替代本身容器
|
||||||
.UseServiceProviderFactory(new AutofacServiceProviderFactory()).
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory()).
|
||||||
ConfigureLogging(logging =>
|
ConfigureLogging(logging =>
|
||||||
{
|
{
|
||||||
logging.ClearProviders();
|
logging.ClearProviders();
|
||||||
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||||
})
|
}).UseSerilog()
|
||||||
.UseNLog()
|
|
||||||
; // NLog: Setup NLog for Dependency injection;
|
; // NLog: Setup NLog for Dependency injection;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.FileProviders;
|
using Microsoft.Extensions.FileProviders;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -114,6 +115,11 @@ namespace IRaCIS.Core.API
|
||||||
// options.MaxRequestBodySize = int.MaxValue;
|
// options.MaxRequestBodySize = int.MaxValue;
|
||||||
//});
|
//});
|
||||||
|
|
||||||
|
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.WriteTo.Console() // 选择日志输出目标,可以选择文件、数据库等
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -162,6 +168,8 @@ namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Log.Information("计费系统启动...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue