public static void LogException(string errorType, Exception ex, string message = null) { var sb = new StringBuilder(); while (ex != null) { if (sb.Length > 0) { sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); } sb.Append(ex.Message); sb.Append(Environment.NewLine); sb.Append(ex.StackTrace); ex = ex.InnerException; } var currentUrl = HttpContext.Current != null ? CurrentUrl : "CurrentUrl not available"; LogExceptions.Insert(DateTime.UtcNow, Environment.MachineName, errorType, currentUrl, message, sb.ToString()); }