| | |
| | | using Autofac; |
| | | using Autofac.Core; |
| | | using Autofac.Extensions.DependencyInjection; |
| | | using Magicodes.ExporterAndImporter.Excel.Utility.TemplateExport; |
| | | using Microsoft.AspNetCore.Builder; |
| | | using Microsoft.AspNetCore.Mvc.Controllers; |
| | | using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; |
| | |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.QuartzExtensions; |
| | | using WIDESEAWCS_QuartzJob.Seed; |
| | | using WIDESEAWCS_RedisService.Extensions; |
| | | using WIDESEAWCS_Server.Filter; |
| | | using WIDESEAWCS_Server.HostedService; |
| | | using WIDESEAWCS_Tasks.SocketServer; |
| | | using WIDESEAWCS_RedisService.Extensions; |
| | | using WIDESEAWCS_WCSServer.Filter; |
| | | |
| | | var builder = WebApplication.CreateBuilder(args); |
| | |
| | | // 这样可以减少Microsoft框架本身的详细日志,避免过多的Debug日志 |
| | | .MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
| | | .WriteTo.Console() // 添加控制台输出接收器,日志将显示在控制台窗口中 |
| | | // 添加文件输出接收器,将日志写入文件系统 |
| | | // 添加文件输出接收器,将日志写入文件系统 |
| | | .WriteTo.File( |
| | | /*Path.Combine(AppContext.BaseDirectory, "Logs", "serilog-.log"),*/ // 指定日志文件的完整路径:应用程序目录 + "Log"文件夹 + "serilog-日期.log" |
| | | "logs/serilog-.log", |
| | | rollingInterval: RollingInterval.Day, // 设置日志文件按天滚动,每天生成一个新的日志文件 |
| | | rollingInterval: RollingInterval.Day, // 设置日志文件按天滚动,每天生成一个新的日志文件 U1od4UGVsIKZG39S5Yak |
| | | retainedFileCountLimit: 30, // 最多保留最近30天的日志文件,超过30天的文件会自动删除 |
| | | shared: true); // 允许多个进程同时写入同一个日志文件,适用于多实例部署场景 |
| | | shared: true) // 允许多个进程同时写入同一个日志文件,适用于多实例部署场景 |
| | | .WriteTo.Seq( |
| | | serverUrl: "http://localhost:5341", |
| | | apiKey: "U1od4UGVsIKZG39S5Yak", // 如Seq需要ApiKey则配置真实密钥 |
| | | batchPostingLimit: 1000, // 批量发送数量 |
| | | period: TimeSpan.FromSeconds(2) // 发送间隔 |
| | | ); |
| | | }); |
| | | |
| | | builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder => |
| | |
| | | |
| | | builder.Services.AddMemoryCacheSetup(); // 内存缓存 |
| | | builder.Services.AddRedisSetup(builder.Configuration); // Redis 缓存 |
| | | builder.Services.AddHostedService<ApiRouteCacheWarmupHostedService>(); // API路由缓存预热(Redis就绪后加载) |
| | | builder.Services.AddSqlsugarSetup(); // SqlSugar 数据库配置 |
| | | builder.Services.AddInitializationHostServiceSetup(); // 应用初始化相关后台服务 |
| | | builder.Services.AddHostedService<SeedDataHostedService>(); // 启动时种子数据初始化 |