Using System.Windows.Forms;
Using System.IO;
public static void Createlog (Exception ex)
{
String path = Application.startuppath + "\\Log";
if (! Directory.Exists (PATH))
{
Directory.CreateDirectory (path);
}
Path + = "\" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + datetime.now.hour+datetime.now.minute+ ". txt";
Writel (path, ex);
}
public static void Writel (string path, Exception ex)
{
using (StreamWriter SW = new StreamWriter (Path,false,encoding.utf8))
{
Sw. WriteLine ("*********************"
+datetime.now.tostring ()
+"*********************");
if (ex! = null)
{
Sw. WriteLine ("[ErrorType]---" + ex. GetType ());//Gets the type of the current running instance
Sw. WriteLine ("[TargetSite]---" + ex. TargetSite);//Get a way to trigger a
Sw. WriteLine ("[Message]---" + ex. message);//Get information about the current one
Sw. WriteLine ("[Source]---" + ex. Source);//Gets the name of the application and object that caused the exception to occur
Sw. WriteLine ("[StackTrace]---" + ex. StackTrace);//stack to trace anomalies
}
Else
Sw. WriteLine ("Exception is null");
Sw. WriteLine ();
}
}
About C # Exception Log processing