Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public class Logger
  2. {
  3. public static void WriteLog(string rootFolder, string message)
  4. {
  5. message = DateTime.Now.ToString("yyyy/MM/dd hh:mm") + " - " + message;
  6. string[] lines = { message };
  7.  
  8. var filePath = rootFolder + @"\" + DateTime.Now.ToString("yyyy-MM-dd") + @"_Site.log";
  9.  
  10. // This text is added only once to the file.
  11. if (!File.Exists(filePath))
  12. {
  13. // Create a file to write to.
  14. System.IO.File.WriteAllLines(filePath, lines);
  15. }
  16. else
  17. {
  18. File.AppendAllText(filePath, message + Environment.NewLine);
  19. }
  20.  
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement