lu
2024-10-25 fe09fca3e77be09fed738a975ff9c5a508c2dd0d
DevApp/Gs.DevApp/ToolBox/LogHelper.cs
@@ -1,12 +1,16 @@
using System;
using DevExpress.XtraRichEdit.Export.Rtf;
using System;
using System.Configuration;
using System.IO;
using System.Windows.Shapes;
namespace Gs.DevApp.ToolBox
{
    public class LogHelper
    {
        //创建日志目录
        private static string path = AppContext.BaseDirectory + System.Configuration.ConfigurationSettings.AppSettings.Get("LogPath").ToString();
        private static string path = AppContext.BaseDirectory + ConfigurationManager.AppSettings["LogPath"].ToString();
        /**
         * 向日志文件写入调试信息
         * @param className 类名
@@ -31,13 +35,14 @@
            }
            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);
            //向日志文件写入内容
            string write_content = time + " " + type + " " + className + ": " + content;
            mySw.WriteLine(write_content);
            //关闭日志文件
            mySw.Close();
        }
    }
}