using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; namespace Chat.Framework.Utils { public class LogHelper { #region //将显示的提示信息写到Log文件 public void Write(string fileName, string tipMsg) { try { using (StreamWriter SW = new StreamWriter(fileName, true, Encoding.UTF8)) { if (File.Exists(fileName) == false) { File.Create(fileName); } //将内容写到log文件中 SW.WriteLine("【" + DateTime.Now.ToString("HH:mm:ss") + "】" + tipMsg); //刷新,实时保存 SW.Flush(); } } catch (Exception ) { // System.Diagnostics.Debug.Print("TraceLog Error:" + ex.Message.ToString()); } } #endregion //将消息写到Log文件 } }