Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Logger
- {
- public static void WriteLog(string rootFolder, string message)
- {
- message = DateTime.Now.ToString("yyyy/MM/dd hh:mm") + " - " + message;
- string[] lines = { message };
- var filePath = rootFolder + @"\" + DateTime.Now.ToString("yyyy-MM-dd") + @"_Site.log";
- // This text is added only once to the file.
- if (!File.Exists(filePath))
- {
- // Create a file to write to.
- System.IO.File.WriteAllLines(filePath, lines);
- }
- else
- {
- File.AppendAllText(filePath, message + Environment.NewLine);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement