Wednesday, November 11, 2009

Create Error Log Files


public CreateLogFiles()
{
sLogFormat = DateTime.Now.ToShortDateString().ToString()+” “+DateTime.Now.ToLongTimeString().ToString()+” ==> “;
string sYear    = DateTime.Now.Year.ToString();
string sMonth    = DateTime.Now.Month.ToString();
string sDay    = DateTime.Now.Day.ToString();
sErrorTime = sYear+sMonth+sDay;
}
public void ErrorLog(string sPathName, string sErrMsg)
{
StreamWriter sw = new StreamWriter(sPathName+sErrorTime,true);
sw.WriteLine(sLogFormat + sErrMsg);
sw.Flush();
sw.Close();
}

No comments:

Post a Comment