林豪 左 2 năm trước cách đây
mục cha
commit
0a10342619
1 tập tin đã thay đổi với 11 bổ sung3 xóa
  1. 11 3
      ServiceCenter/LogHub.cs

+ 11 - 3
ServiceCenter/LogHub.cs

@@ -2,6 +2,7 @@
 using ServiceCenter.Extensions;
 using ServiceCenter.Redis;
 using System.Collections.Concurrent;
+using WCS.Core;
 
 namespace ServiceCenter
 {
@@ -48,10 +49,17 @@ namespace ServiceCenter
             while (true)
             {
                 var log = JsonConvert.DeserializeObject<LogModel>(RedisHub.Default.LPop("LogHub"));
-                if (log != null)
+                try
                 {
-                    if (!Directory.Exists(log.path)) Directory.CreateDirectory(log.path);
-                    File.AppendAllText(Path.Combine(log.path, log.Title), log.Con);
+                    if (log != null)
+                    {
+                        if (!Directory.Exists(log.path)) Directory.CreateDirectory(log.path);
+                        File.AppendAllText(Path.Combine(log.path, log.Title), log.Con);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    File.AppendAllText(Path.Combine($"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\日志处理进程", "Error.txt"), $"{JsonConvert.SerializeObject(log)}--{ex.Message}--{ex.StackTrace}\n");
                 }
             }
         }