-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExceptionLogger.cs
28 lines (27 loc) · 949 Bytes
/
ExceptionLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;
using System.Reflection;
namespace PdfFunctions
{
public static class ExceptionLogger
{
private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static void logException(Exception ex)
{
var sb = new StringBuilder(ex.ToString());
sb.AppendLine("--TARGET SITE--");
sb.AppendLine(ex.TargetSite.Name);
sb.AppendLine("--INNER EXCEPTION");
sb.AppendLine(ex.InnerException != null ? ex.InnerException.ToString() : "N/A");
sb.AppendLine("--SOURCE--");
sb.AppendLine(ex.Source);
sb.AppendLine("--STACK TRACE--");
sb.AppendLine(ex.StackTrace);
Log.Error(sb.ToString(), ex);
}
}
}