Saturday, November 23, 2019

Logging Exceptions to Fileshare C# .NET

Logging exceptions to Fileshare using C#.NET. Sample code.

try
{
 string filePath = @"\\sharepointFix\Error.txt";
 .............
.............
}
catch
{
                using (StreamWriter writer = new StreamWriter(filePath, true))
              {
                    writer.WriteLine("Message: " + exp.Message + Environment.NewLine + "Stack Trace : " + exp.StackTrace
                        + Environment.NewLine + "Inner Exception: " + exp.InnerException
                        + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                }
}

No comments:

Post a Comment