From d70880a3d9ae6c9f99ec380ccd16f5524bb622e6 Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期六, 05 四月 2025 09:06:31 +0800 Subject: [PATCH] 修改按钮状态 --- DevApp/Gs.DevApp/ToolBox/LogHelper.cs | 38 ++++++++++++++++++++++---------------- 1 files changed, 22 insertions(+), 16 deletions(-) diff --git a/DevApp/Gs.DevApp/ToolBox/LogHelper.cs b/DevApp/Gs.DevApp/ToolBox/LogHelper.cs index 4e79ca2..3a05fda 100644 --- a/DevApp/Gs.DevApp/ToolBox/LogHelper.cs +++ b/DevApp/Gs.DevApp/ToolBox/LogHelper.cs @@ -1,4 +1,5 @@ 锘縰sing System; +using System.Configuration; using System.IO; namespace Gs.DevApp.ToolBox @@ -6,7 +7,10 @@ public class LogHelper { //鍒涘缓鏃ュ織鐩綍 - private static string path = AppContext.BaseDirectory + System.Configuration.ConfigurationSettings.AppSettings.Get("LogPath").ToString(); + private static readonly string path = AppContext.BaseDirectory + + ConfigurationManager.AppSettings[ + "LogPath"]; + /** * 鍚戞棩蹇楁枃浠跺啓鍏ヨ皟璇曚俊鎭� * @param className 绫诲悕 @@ -18,26 +22,28 @@ } /** - * 瀹為檯鐨勫啓鏃ュ織鎿嶄綔 - * @param type 鏃ュ織璁板綍绫诲瀷 - * @param className 绫诲悕 - * @param content 鍐欏叆鍐呭 - */ - protected static void WriteLog(string type, string className, string content) + * 瀹為檯鐨勫啓鏃ュ織鎿嶄綔 + * @param type 鏃ュ織璁板綍绫诲瀷 + * @param className 绫诲悕 + * @param content 鍐欏叆鍐呭 + */ + protected static void WriteLog(string type, string className, + string content) { - if (!Directory.Exists(path))//濡傛灉鏃ュ織鐩綍涓嶅瓨鍦ㄥ氨鍒涘缓 - { + if (!Directory.Exists(path)) //濡傛灉鏃ュ織鐩綍涓嶅瓨鍦ㄥ氨鍒涘缓 Directory.CreateDirectory(path); - } - string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");//鑾峰彇褰撳墠绯荤粺鏃堕棿 - string filename = path + "/" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";//鐢ㄦ棩鏈熷鏃ュ織鏂囦欢鍛藉悕 - //鍒涘缓鎴栨墦寮�鏃ュ織鏂囦欢锛屽悜鏃ュ織鏂囦欢鏈熬杩藉姞璁板綍 - StreamWriter mySw = File.AppendText(filename); + var time = + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); //鑾峰彇褰撳墠绯荤粺鏃堕棿 + var filename = path + "/" + DateTime.Now.ToString("yyyy-MM-dd") + + ".log"; //鐢ㄦ棩鏈熷鏃ュ織鏂囦欢鍛藉悕 + //鍒涘缓鎴栨墦寮�鏃ュ織鏂囦欢锛屽悜鏃ュ織鏂囦欢鏈熬杩藉姞璁板綍 + var mySw = File.AppendText(filename); //鍚戞棩蹇楁枃浠跺啓鍏ュ唴瀹� - string write_content = time + " " + type + " " + className + ": " + content; + var write_content = + time + " " + type + " " + className + ": " + content; mySw.WriteLine(write_content); //鍏抽棴鏃ュ織鏂囦欢 mySw.Close(); } } -} +} \ No newline at end of file -- Gitblit v1.9.3