示例#1
0
 /// <summary>
 /// Writing exception to log file  along with user id including form name in which the exception occured
 /// </summary>
 /// <param name="ex">exception</param>
 /// <param name="LogFilePath">File path</param>
 /// <param name="UserID">User ID</param>
 /// <param name="FormName">Form Name</param>
 /// <param name="ProjectName">Project Name</param>
 /// <param name="MethodName">Method Name</param>
 public static void WriteToLog(Exception ex, string LogFilePath, string UserID, string FormName, string ProjectName, string MethodName)
 {
     EXCEPTION_UTILITY.FileExceedSize(LogFilePath);
     if (IfThreadAbort(ex))
     {
         StreamWriter _sw  = new StreamWriter(LogFilePath, true);
         Random       rand = new Random();
         string       ID   = Convert.ToString(rand.Next()) + "-" + string.Format("{0:ddMMyyyyHHmmss}", System.DateTime.Now);
         _sw.WriteLine("Id: {0}", ID);
         _sw.WriteLine("UserID: {0}", UserID);
         _sw.WriteLine("Form Name: {0}", FormName);
         _sw.WriteLine("project Name: {0}", ProjectName);
         _sw.WriteLine("Method: {0}", MethodName);
         _sw.WriteLine("Type: {0}", ex.GetType());
         _sw.WriteLine("Source: {0}", ex.Source);
         _sw.WriteLine("Message: {0}", ex.Message);
         _sw.WriteLine("------------------------------------------------------------------------------------");
         _sw.WriteLine();
         _sw.Close();
     }
 }