Over a million developers have joined DZone.

C#: Log A Message To A File

·

// Put this at the top
using System.IO;
//

public static void Log(string Message)
{
	File.AppendAllText(HttpContext.Current.Server.MapPath("~") + "/log.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ": " + Message + Environment.NewLine);
}
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}