Simple Log File


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. private void Log(string txt)
  2. {
  3. string logFile = Server.MapPath("/") + "log.txt";
  4.  
  5. // create a writer and open the file
  6. TextWriter tw = new StreamWriter(logFile, true);
  7.  
  8. // write a line of text to the file
  9. tw.WriteLine(DateTime.Now + " >> " + txt);
  10.  
  11. // close the stream
  12. tw.Close();
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.