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

 

二、通过插件

 

posted @ 2015-08-26 18:48  慧由心生  阅读(452)  评论(0)    收藏  举报