C#:写日志

一、直接写入文件

 /// <summary>
        /// 将message的内容写入日志文件
        /// </summary>
        /// <param name="msg"></param>
        public static void WriteLog(string msg)
        {
            string path = Application.StartupPath + "\logFile";
            File.AppendAllText(path, string.Format("[{0}] : {1}{2}", DateTime.Now, msg, Environment.NewLine));
        }    
View Code

二、通过插件

原文地址:https://www.cnblogs.com/shenchao/p/4761377.html