C# 简单的写日志的方法

    private void WriteLog(string text)
    {

      string path = AppDomain.CurrentDomain.BaseDirectory;
      path = System.IO.Path.Combine(path
        ,"OutputStreamLogs\\"+DateTime.Now.ToString("yy-MM-dd"));

      if (!System.IO.Directory.Exists(path))
      {
        System.IO.Directory.CreateDirectory(path);
      }
      string fileFullName = System.IO.Path.Combine(path
        , string.Format("{0}.log", DateTime.Now.ToString("yyMMdd-HHmmss")));


      using (StreamWriter output = System.IO.File.AppendText(fileFullName))
      {
        output.WriteLine(text);

        output.Close();
      }
    }

 

转载保留:http://write.blog.csdn.net/postedit/7793112

posted @ 2012-07-27 13:00  草青工作室  阅读(189)  评论(0编辑  收藏  举报