From 6e9f630e4e12738d98241b684e6227e02010b6c5 Mon Sep 17 00:00:00 2001
From: Huangxiaoqiang-03 <1247017146@qq.com>
Date: 星期五, 01 十一月 2024 17:30:30 +0800
Subject: [PATCH] 1

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/Logger.cs |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/Logger.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/Logger.cs"
index 7e58409..4995e84 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/Logger.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/Logger.cs"
@@ -1,5 +1,6 @@
 锘�
 using Microsoft.AspNetCore.Http;
+using Newtonsoft.Json;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -65,6 +66,40 @@
         {
 
         }
+        public static void Write_Log(string groupName, string logName, string content, object data = null)
+        {
+            DateTime nowTime = DateTime.Now;
+            string basePath = System.Environment.CurrentDirectory + "/Log/" + $"/{groupName}/{nowTime.ToString("yyyy-MM-dd")}";
+            //濡傛灉鏃ュ織鏂囦欢鐩綍涓嶅瓨鍦�,鍒欏垱寤�
+            if (!Directory.Exists(basePath))
+            {
+                Directory.CreateDirectory(basePath);
+            }
+            try
+            {
+                FileStream fs = new FileStream(basePath + "/" + logName + $"{nowTime.ToString("yyMMdd")}.txt", FileMode.Append);
+                StreamWriter strwriter = new StreamWriter(fs);
+                try
+                {
+                    strwriter.WriteLine(nowTime.ToString() + "." + nowTime.Millisecond);
+                    strwriter.WriteLine(content);
+                    if (data != null)
+                    {
+                        strwriter.WriteLine(JsonConvert.SerializeObject(data));
+                    }
+                    strwriter.WriteLine("-------------------------------");
+                    strwriter.WriteLine();
+                    strwriter.Flush();
+                }
+                catch { }
+                finally
+                {
+                    strwriter.Close();
+                    fs.Close();
+                }
+            }
+            catch { }
+        }
 
         public static void WriteApiLog2DB(HttpContext context, string requestParameter, DateTime beginDate, string responseParameter, DateTime endDate, LoggerStatus loggerStatus)
         {

--
Gitblit v1.9.3