Hi,
I am trying to Log the exceptions using Logging block in Flat File. For this purpose I have defined configuration in web.config file and below is the code.
I have created a utility function to log exceptions. But I am getting âThread was being aborted.â Error. Below is the CallsStack:
Extended Properties:
Callstack= at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Diagnostics.TraceEventCache.get_Callstack()
at System.Diagnostics.TraceListener.WriteFooter(Trace EventCache eventCache)
at System.Diagnostics.TraceListener.TraceData(TraceEv entCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
at Microsoft.Practices.EnterpriseLibrary.Logging.Trac eListeners.FormattedTextWriterTraceListener.TraceD ata(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
at Microsoft.Practices.EnterpriseLibrary.Logging.Trac eListeners.FlatFileTraceListener.TraceData(TraceEv entCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogS ource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogW riter.ProcessLog(LogEntry log)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogW riter.Write(LogEntry log)
at Microsoft.Practices.EnterpriseLibrary.Logging.Logg er.Write(LogEntry log)
at AppUtilityMethods.LogExceptionEntry(Exception ex) in D:\Personal\CargoXpert\WebUI\App_Code\AppUtilityMe thods.
vb:line 12
at _Default.Page_Load(Object sender, EventArgs e) in D:\Personal\CargoXpert\WebUI\Default.aspx.
vb:line 36 at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.default_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.ResumeSteps(Exception error)
at System.Web.HttpApplication.System.Web.IHttpAsyncHa ndler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpRuntime.ProcessRequestInternal(Http WorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequestNow(HttpWorke rRequest wr)
at System.Web.HttpRuntime.ProcessRequestNoDemand(Http WorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequest(HttpWorkerRe quest wr)
at Microsoft.VisualStudio.WebHost.Request.Process()
at Microsoft.VisualStudio.WebHost.Host.ProcessRequest (Connection conn)
Below is the code.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = True Then
Try
â Some Code here
Catch ex As Exception
AppUtilityMethods.LogExceptionEntry(ex)
lblError.Text = "<br />Written to Application Event Log"
End Try
End If
End Sub
Public Class AppUtilityMethods
Public Shared Sub LogExceptionEntry(ByVal ex As Exception)
Dim log As LogEntry = New LogEntry()
log.EventId = 6001
log.Message = ex.Message
log.Severity = Diagnostics.TraceEventType.Error
log.Priority = 5
Logger.Write(log)
End Sub
End Class