C#中简单的写日志的方法

时间:2014-06-07 07:15:18   收藏:0   阅读:292

public static void WriteLog(string msg)
        {
            string appPath = AppDomain.CurrentDomain.BaseDirectory;
            string ServerPath = appPath + @"\Log" + DateTime.Now.ToString("yyyyMMdd") + ".txt";

            StreamWriter srWriter = new StreamWriter(ServerPath, true);
            string WriteStr = "************************************************************************************************\r\n";
            WriteStr += "Date:" + DateTime.Now.ToString() + "  \r\n" + msg;
            srWriter.WriteLine(WriteStr);
            srWriter.Close();
        }

C#中简单的写日志的方法,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!