From 5e851678cc02257bbbd179446de36082430ca5bc Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 13 四月 2026 15:12:04 +0800
Subject: [PATCH] feat(MES): 添加Mes_Log扩展逻辑
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
index 377148e..9bd9909 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
@@ -1,6 +1,7 @@
锘縰sing 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;
@@ -27,10 +28,10 @@
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);
@@ -45,18 +46,24 @@
.ReadFrom.Configuration(context.Configuration) // 浠庡簲鐢ㄧ▼搴忛厤缃腑璇诲彇Serilog鐩稿叧璁剧疆锛堝appsettings.json锛�
.ReadFrom.Services(services) // 浠庝緷璧栨敞鍏ュ鍣ㄤ腑璇诲彇鏈嶅姟閰嶇疆锛屽厑璁稿湪閰嶇疆涓娇鐢ㄥ凡娉ㄥ唽鐨勬湇鍔�
.Enrich.FromLogContext() // 鍚敤鏃ュ織涓婁笅鏂囷紝鍙互鍦ㄦ棩蹇椾腑鍖呭惈濡傝姹侷D銆佺敤鎴稩D绛夊姩鎬佸睘鎬�
-
+ .Enrich.WithProperty("Application", "WCS")
// 璁剧疆Microsoft鍛藉悕绌洪棿鐨勬棩蹇楃骇鍒负Information
// 杩欐牱鍙互鍑忓皯Microsoft妗嗘灦鏈韩鐨勮缁嗘棩蹇楋紝閬垮厤杩囧鐨凞ebug鏃ュ織
.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", // 濡係eq闇�瑕丄piKey鍒欓厤缃湡瀹炲瘑閽�
+ batchPostingLimit: 1000, // 鎵归噺鍙戦�佹暟閲�
+ period: TimeSpan.FromSeconds(2) // 鍙戦�侀棿闅�
+ );
});
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder =>
@@ -80,6 +87,7 @@
builder.Services.AddMemoryCacheSetup(); // 鍐呭瓨缂撳瓨
builder.Services.AddRedisSetup(builder.Configuration); // Redis 缂撳瓨
+builder.Services.AddHostedService<ApiRouteCacheWarmupHostedService>(); // API璺敱缂撳瓨棰勭儹锛圧edis灏辩华鍚庡姞杞斤級
builder.Services.AddSqlsugarSetup(); // SqlSugar 鏁版嵁搴撻厤缃�
builder.Services.AddInitializationHostServiceSetup(); // 搴旂敤鍒濆鍖栫浉鍏冲悗鍙版湇鍔�
builder.Services.AddHostedService<SeedDataHostedService>(); // 鍚姩鏃剁瀛愭暟鎹垵濮嬪寲
--
Gitblit v1.9.3